简体   繁体   English

从 Powershell 调用 C# dll

[英]Calling C# dll from Powershell

I have got simple dll, it's get url and on output cuted url of image.我有简单的 dll,它得到 url 和 output 切割 Z572D4E421E5E6B71112 图像。

It's source http://www.everfall.com/paste/id.php?74eupvt40xzf它的来源http://www.everfall.com/paste/id.php?74eupvt40xzf

I'm trying to call it end send url to it in PowerShell我试图在 PowerShell 中将其称为结束发送 url 给它

$url = "http://oiswww.eumetsat.org/IPPS/html/MSG/RGB/AIRMASS/"
[Reflection.Assembly]::LoadFrom(“D:\maps\eumetsat\cuturl.dll”)
[parser.Util]::GetUrl($url)

But when I run test.ps1 I got error that can't find type [cuturl.GetURL] please be sure that building with is are loaded.但是当我运行 test.ps1 时,我得到了找不到类型 [cuturl.GetURL] 的错误,请确保加载了 build with 。

What I do wrong?我做错了什么?

And second question, how I can get cutted link back from lib?第二个问题,我如何才能从 lib 中恢复链接? with which function?与哪个 function?

If I compile your code 'cuturl.cs' with the following command line, all works well.如果我使用以下命令行编译您的代码“cuturl.cs”,一切正常。 Except that the method return "",除了方法返回“”,

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\csc /target:library.\cuturl.cs C:\Windows\Microsoft.NET\Framework64\v2.0.50727\csc /target:library.\cuturl.cs

After saving the code locally I used this to load it in V2 of PowerShell:在本地保存代码后,我使用它在 PowerShell 的 V2 中加载它:

add-type -path D:\PowerShellModuleRepository\Parser.Util.cs

As JPBlanc said the code returns nothing though:正如 JPBlanc 所说,代码虽然没有返回任何内容:

[Parser.Util]::GetUrl("http://www.google.co.uk")

Matt马特

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM