从 PowerShell 使用 .NET 库 [英] Using .NET library from PowerShell

查看:51
本文介绍了从 PowerShell 使用 .NET 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于操作数据库的 PowerShell 管理单元.管理单元本身只是在一个单独的 .NET DLL 中实现的主库的包装器,所有的 .NET DLL 都是用 C# 编写的.

I have a PowerShell snap-in for manipulating a database. The snap-in itself is just a wrapper for the main library implemented in a separate .NET DLL all written in c#.

我已经使用 installutil.exe 向 GAC 注册了管理单元和实现 DLL

I have registered both the snap-in and the implementation DLLs with the GAC using installutil.exe

虽然管理单元在 PowerShell 中工作正常,但我需要能够访问实现 DLL 的详细信息,例如枚举等,以便作为参数传递给 cmdlet.

Whilst the snap-in works fine in PowerShell, I need to be able to access the implementation DLL details for things like enums and the like for passing through as arguments to the cmdlets.

不幸的是,我无法访问 PowerShell 中类的内容,即使这些类被标记为公开,而且我尝试访问的所有内容也被标记为公开.

Unfortunately, I can't access the contents of the classes inside PowerShell even though the classes are marked as public and everything I'm trying to access is also marked as public.

我是否必须对实现 DLL 做一些特殊处理才能使其在 PowerShell 中可见?

Do I have to do something special to the implementation DLL in order to make it visible inside PowerShell?

推荐答案

Add-Type -AssemblyName "Your.Assembly.Name"

善良,

这篇关于从 PowerShell 使用 .NET 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆