相关疑难解决方法(0)

什么是.NET中的GAC?

只是为外行寻找GAC的简短概述,而不是链接.

.net gac

180
推荐指数
8
解决办法
12万
查看次数

加载.NET程序集依赖项不起作用

我一直在寻找一个解决方案.在我的案例中,没有一个答案适用于从PowerShell会话引用(加载?)程序集.NET到app域.

我首先加载引用(需要由上述DLL引用才能工作[Reflection.Assembly]::LoadFile()或者[Reflection.Assembly]::LoadFrom())然后通过调用加载我的.NET DLL Add-Type.

不幸的是,这不起作用,所以我无法从该DLL创建一些实例.当我使用DLL但没有在正常的C#项目中附加引用时,我得到了相同的错误但是一旦我引用其他程序集并重新编译它就没有错误(我可以确认它是因为我在LinqPad中检查了引用的程序集好).

电源外壳:

[System.Reflection.Assembly]::LoadFile((Get-Item -Path ".\System.Data.SQLite.dll" ).FullName)
Add-Type -Path (Get-Item -Path ".\Connector.dll" ).FullName -ReferencedAssemblies (Get-Item -Path ".\System.Data.SQLite.dll" ).FullName -PassThru | Out-Null
$certMGT = New-Object Connector
Run Code Online (Sandbox Code Playgroud)

该PowerShell脚本的第三行抛出:

New-Object : Exception calling ".ctor" with "0" argument(s): "Failed to find or load the registered .Net Framework Data Provider."
At C:\Repos\Connector\bin\Installer.ps1:306 char:20
+         $certMGT = New-Object Connector
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

PSMessageDetails      : 
Exception             : System.Management.Automation.MethodInvocationException: Exception …
Run Code Online (Sandbox Code Playgroud)

c# dll powershell .net-assembly

6
推荐指数
1
解决办法
1312
查看次数

标签 统计

.net ×1

.net-assembly ×1

c# ×1

dll ×1

gac ×1

powershell ×1