gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 14:00:44 24 4
gpt4 key购买 nike

我正在尝试使用 OpenPop.NET 访问 gmail 帐户,但即使使用基本测试代码,我也会收到以下错误消息。

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'OpenPop, Version=2.0.4.369, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 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()

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. To turn this feature off, remove the registry value [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()

我正在尝试在装有 .NET Framework 3.5 和 4 的 Windows 7 机器上的 SQL Server Business Intelligence Development Studio 2008 中的 SSIS 包中执行此操作。OpenPop dll 和引用它的脚本任务都在内置3.5.我已经对此进行了几天的研究,但一直无法找到任何可以修复它的方法。我尝试从源代码重新编译 OpenPop dll,并多次删除和重新添加引用。

我目前正在使用的代码发布在下面:

        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;

提前谢谢你。

最佳答案

我也遇到过这个问题,解决方法其实很简单。您必须将引用的程序集安装到运行该程序包的服务器的 GAC。

1) 验证程序集是否已签名,如果您创建了自己的程序集,请对其进行签名。

2) 使用 Visual Studio SDK 工具中的 gacutil.exe 将 DLL 安装到 GAC。有关详细信息,请参阅 How to: Install an Assembly into the Global Assembly Cache .

3) 从您的脚本任务中引用相同的 DLL

瞧,它现在应该可以完美运行了!

关于C#:无法加载文件或程序集 'OpenPop, Version=2.0.4.369, Culture=neutral, PublicKeyToken=null' 或其依赖项之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9999441/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com