无法加载文件或程序集的AForge,版本=2.2.4.0,……

时间:2021-09-24 03:03:42

I have no problems using AForge classes in a Windows Form application in Visual Studio. I am now trying to use them in Windows PowerShell.

在Visual Studio的Windows窗体应用程序中使用AForge类没有问题。我现在正尝试在Windows PowerShell中使用它们。

[Reflection.Assembly]::LoadFile('C:\Program Files\AForge.NET\IPLab\References\AForge.NET\AForge.Imaging.dll')

gives:

给:

GAC    Version        Location
---    -------        --------
False  v2.0.50727     C:\Program Files\AForge.NET\IPLab\References\AForge.NET\AForge.Imaging.dll

It says v2.0.50727 even though the AForge.Imaging.dll File Version and Product Version are both 2.2.4.0. But I have no problems executing the following to instantiate an AForge.Imaging.UnmanagedImage object $umi (where $bmdata is an Drawing.BitMapData object):

它写的是v2.0.50727,即使是上述。imaging。dll文件版本和产品版本都是2.2.4.0。但是,执行以下操作来实例化AForge.Imaging没有问题。UnmanagedImage对象$umi(其中$bmdata是绘图。BitMapData对象):

$umi = new-object Aforge.Imaging.UnmanagedImage $bmdata

But the moment I tried to access the $umi object, for example $umi.GetType(), I get the following error:

但是,当我试图访问$umi对象(例如$ ui . gettype())时,我得到以下错误:

The following exception occurred while retrieving member "GetType": "Could not load file or assembly 'AForge, Version=2.2.4.0, Culture=neutral, PublicKeyToken=c1db6ff4eaa06aeb' or one of its dependencies. The system cannot find the file specified."
At line:1 char:13
+ $umi.GetType <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

What could be wrong? Thanks.

可能是错的呢?谢谢。

3 个解决方案

#1


3  

The "AForge.Imaging.dll" library depends on the following libraries that must also be loaded;

“AForge.Imaging。dll“库依赖于以下库,这些库也必须被加载;

Add-Type -AssemblyName "System.Drawing"
Add-Type -Path "E:\AForge.dll"
Add-Type -Path "E:\AForge.Math.dll"
Add-Type -Path "E:\AForge.Imaging.dll"

run the following PowerShell command to list the currently loaded assemblies and verify you have the necessary bits.

运行下面的PowerShell命令列出当前加载的程序集,并验证是否有必要的位。

[appdomain]::currentdomain.getassemblies() | sort -property fullname | format-table fullname

Here were my results:

这是我的结果:

FullName
--------
AForge, Version=2.2.4.0, Culture=neutral, PublicKeyToken=c1db6ff4eaa06aeb
AForge.Imaging, Version=2.2.4.0, Culture=neutral, PublicKeyToken=ba8ddea9676ca48b
AForge.Math, Version=2.2.4.0, Culture=neutral, PublicKeyToken=abba2e25397ee8c9
Microsoft.PowerShell.Commands.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.Commands.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.Commands.Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.WSMan.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

I can confirm this worked for me.

我可以确认这对我有效。

#2


0  

Run Process Monitor and check what assembly it is looking for and where. It may be that one of the assemblies needed by AForge.NET cannot be found, or some security limitations. Sometimes similar problems can be if you are trying to load 32 bit version of DLL into 64 bit powershell and vice versa

运行进程监视器并检查它正在查找的程序集和位置。它可能是AForge所需要的集合之一。无法找到NET或某些安全限制。有时,如果您试图将32位的DLL版本加载到64位的powershell中,反之亦然。

#3


0  

Install aforge.video in project from where you are calling function- Following is the syntax for nuget console Install-Package AForge.Video -Project "ProjectNameFromWhichAforgeFunctionCalls" -Version 2.2.4.0

安装aforge。在项目中调用函数的视频-以下是nuget控制台安装的语法-包AForge。视频-项目“project namefromwhichaforgefunctioncall”-Version 2.4.0

This solved my problem

这解决了我的问题

#1


3  

The "AForge.Imaging.dll" library depends on the following libraries that must also be loaded;

“AForge.Imaging。dll“库依赖于以下库,这些库也必须被加载;

Add-Type -AssemblyName "System.Drawing"
Add-Type -Path "E:\AForge.dll"
Add-Type -Path "E:\AForge.Math.dll"
Add-Type -Path "E:\AForge.Imaging.dll"

run the following PowerShell command to list the currently loaded assemblies and verify you have the necessary bits.

运行下面的PowerShell命令列出当前加载的程序集,并验证是否有必要的位。

[appdomain]::currentdomain.getassemblies() | sort -property fullname | format-table fullname

Here were my results:

这是我的结果:

FullName
--------
AForge, Version=2.2.4.0, Culture=neutral, PublicKeyToken=c1db6ff4eaa06aeb
AForge.Imaging, Version=2.2.4.0, Culture=neutral, PublicKeyToken=ba8ddea9676ca48b
AForge.Math, Version=2.2.4.0, Culture=neutral, PublicKeyToken=abba2e25397ee8c9
Microsoft.PowerShell.Commands.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.Commands.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.Commands.Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.WSMan.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

I can confirm this worked for me.

我可以确认这对我有效。

#2


0  

Run Process Monitor and check what assembly it is looking for and where. It may be that one of the assemblies needed by AForge.NET cannot be found, or some security limitations. Sometimes similar problems can be if you are trying to load 32 bit version of DLL into 64 bit powershell and vice versa

运行进程监视器并检查它正在查找的程序集和位置。它可能是AForge所需要的集合之一。无法找到NET或某些安全限制。有时,如果您试图将32位的DLL版本加载到64位的powershell中,反之亦然。

#3


0  

Install aforge.video in project from where you are calling function- Following is the syntax for nuget console Install-Package AForge.Video -Project "ProjectNameFromWhichAforgeFunctionCalls" -Version 2.2.4.0

安装aforge。在项目中调用函数的视频-以下是nuget控制台安装的语法-包AForge。视频-项目“project namefromwhichaforgefunctioncall”-Version 2.4.0

This solved my problem

这解决了我的问题