简体   繁体   English

C#:无法加载文件或程序集'OpenPop,Version = 2.0.4.369,Culture = neutral,PublicKeyToken = null'或其依赖项之一

[英]C#: Could not load file or assembly 'OpenPop, Version=2.0.4.369, Culture=neutral, PublicKeyToken=null' or one of its dependencies

I am attempting to use OpenPop.NET to access a gmail account, however I am receiving the error message below even with basic testing code. 我正在尝试使用OpenPop.NET访问gmail帐户,但是即使使用基本测试代码,我也会收到以下错误消息。

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 错误:System.Reflection.TargetInvocationException:调用目标已抛出异常。 ---> System.IO.FileNotFoundException: Could not load file or assembly 'OpenPop, Version=2.0.4.369, Culture=neutral, PublicKeyToken=null' or one of its dependencies. ---> System.IO.FileNotFoundException:无法加载文件或程序集'OpenPop,Version = 2.0.4.369,Culture = neutral,PublicKeyToken = null'或其依赖项之一。 The system cannot find the file specified. 该系统找不到指定的文件。 File name: 'OpenPop, Version=2.0.4.369, Culture=neutral, PublicKeyToken=null' at ST_1694f4bcdf2a4068ae871201a2216457.csproj.ScriptMain.Main() 文件名:'OpenPop,Version = 2.0.4.369,Culture = neutral,PublicKeyToken = null'at ST_1694f4bcdf2a4068ae871201a2216457.csproj.ScriptMain.Main()

WRN: Assembly binding logging is turned OFF. 警告:装配绑定日志记录已关闭。 To enable assembly bind failure logging, set the registry value [HKLM\\Software\\Microsoft\\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. 要启用程序集绑定失败日志记录,请将注册表值[HKLM \\ Software \\ Microsoft \\ Fusion!EnableLog](DWORD)设置为1.注意:程序集绑定失败日志记录会导致一些性能损失。 To turn this feature off, remove the registry value [HKLM\\Software\\Microsoft\\Fusion!EnableLog]. 要关闭此功能,请删除注册表值[HKLM \\ Software \\ Microsoft \\ Fusion!EnableLog]。

--- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript() ---内部异常堆栈跟踪的结束---在System.Reflection.RuntimeMethodInfo.Invoke的System.RuntimeMethodHandle._InvokeMethodFast(Object target,Object []参数,SignatureStruct&sig,MethodAttributes methodAttributes,RuntimeTypeHandle typeOwner)中(Object obj,BindingFlags invokeAttr) System.RuntimeType.InvokeMember(String name)上的System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object []参数,CultureInfo文化),Binder binder,Object []参数,CultureInfo文化,布尔值skipVisibilityChecks) ,BindingFlags bindingFlags,Binder binder,Object target,Object [] providedArgs,ParameterModifier [] modifiers,CultureInfo culture,String [] namedParams)at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

I am trying to do this in an SSIS package in SQL Server Business Intelligence Development Studio 2008 on a Windows 7 machine with .NET framework 3.5 and 4. Both the OpenPop dll and the script task that is referencing it are being built in 3.5. 我试图在具有.NET framework 3.5和4的Windows 7计算机上的SQL Server Business Intelligence Development Studio 2008中的SSIS包中执行此操作.OpenPop dll和引用它的脚本任务都是在3.5中构建的。 I have been researching this for a few days but haven't been able to find anything that could fix it. 我已经研究了几天,但一直没能找到任何可以修复它的东西。 I have tried recompiling the OpenPop dll from source and removing and re-adding the reference multiple times. 我尝试从源重新编译OpenPop dll并多次删除和重新添加引用。

The code I am currently working with is posted below: 我目前正在使用的代码发布如下:

        Pop3Client client = new Pop3Client();

        try
        {
            client.Connect("pop.gmail.com", 995, true);

            try
            {
                client.Authenticate("user@domain.com", "mypassword");
                Console.WriteLine("Success");
                client.Disconnect();
            }
            catch
            {
                Console.WriteLine("Failed to authenticate");
                Dts.TaskResult = (int)ScriptResults.Failure;
                return;
            }
        }
        catch
        {
            Console.WriteLine("Failed to connect");
            Dts.TaskResult = (int)ScriptResults.Failure;
            return;
        }

        Dts.TaskResult = (int)ScriptResults.Success;

Thank you in advance. 先感谢您。

Ive experience this problem too and the solution is actually quite simple. 我也遇到过这个问题,解决方案实际上非常简单。 You have to install the referenced assembly to the GAC of the server youre running the package on. 您必须将引用的程序集安装到运行程序包的服务器的GAC上。

1) Verify that the assembly is signed, if you created your own assembly, sign it. 1)验证装配是否已签名,如果您创建了自己的装配,请对其进行签名。

2) Install the DLL to the GAC using gacutil.exe from SDK tools of Visual Studio. 2)使用Visual Studio的SDK工具中的gacutil.exe将DLL安装到GAC。 For more info, see How to: Install an Assembly into the Global Assembly Cache . 有关更多信息,请参见如何:将程序集安装到全局程序集缓存中

3) Reference the same DLL from your Script Task 3)从脚本任务中引用相同的DLL

Voila, it should work perfectly now! 瞧,它现在应该完美运作!

Installing your DLL to GAC(global assembly cache) 将DLL安装到GAC(全局程序集缓存)

1)Visual Studio Command Prompt => Run as Adminstrator 1)Visual Studio命令提示符=>以管理员身份运行

2)gacutil /i "dll file path" 2)gacutil / i“dll文件路径”

3) see assembly on C:\\Windows\\system32\\ 3)在C:\\ Windows \\ system32上看到程序集

It Will also solve dll missing or "Could not load file or assembly" in SSIS Script task 它还将解决SSIS脚本任务中缺少的dll或“无法加载文件或程序集”

暂无
暂无

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

相关问题 无法加载文件或程序集“BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null”或其依赖项之一 - Could not load file or assembly 'BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies 无法加载文件或程序集'XXX,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'或其依赖项之一 - Could not load file or assembly 'XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies 无法加载文件或程序集'Dapper,Version = 1.8.0.0,Culture = neutral,PublicKeyToken = null'或其依赖项之一 - Could not load file or assembly 'Dapper, Version=1.8.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies 无法加载文件或程序集“工具,版本= 4.5.0.0,区域性=中性,PublicKeyToken = f7660c0f5438cda5”或其依赖项之一 - Could not load file or assembly 'Tools, Version=4.5.0.0, Culture=neutral, PublicKeyToken=f7660c0f5438cda5' or one of its dependencies 无法加载文件或程序集“系统,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”或其依赖项之一 - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies 无法加载文件或程序集'System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 561934e089'或其依赖项之一 - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=561934e089' or one of its dependencies 无法加载文件或程序集“Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=myKey”或其依赖项之一。 - Could not load file or assembly 'Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=myKey' or one of its dependencies. 无法加载文件或程序集'itextsharp,Version = 5.5.0.0,Culture = neutral,PublicKeyToken = 8354ae6d2174ddca'或其依赖项之一 - Could not load file or assembly 'itextsharp, Version=5.5.0.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' or one of its dependencies 无法加载文件或程序集“Microsoft.Bcl.AsyncInterfaces,Version=1.0.0.0,Culture=neutral,PublicKeyToken=XX”或其依赖项之一 - Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XX' or one of its dependencies 无法加载文件或程序集“ MySql.Data,版本= 6.9.5.0,区域性=中性,PublicKeyToken = c5687fc88969c44d”或其依赖项之一 - Could not load file or assembly 'MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM