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

I am trying to use OpenPop.NET to access a gmail account, however I am getting below error even with basic testing code.

Error: System.Reflection.TargetInvocationException: An exception was thrown by the target of the call. ---> 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. Filename: 'OpenPop, Version = 2.0.4.369, Culture = neutral, PublicKeyToken = null' at ST_1694f4bcdf2a4068ae871201a2216457.csproj.ScriptMain.Main ()

WRN: Assembly binding registration is disabled. To enable Build Failure Logging, set the registry value [HKLM \ Software \ Microsoft \ Fusion! EnableLog] (DWORD) to 1. Note. There is some performance limitation related to the assembly binding failure protocol. To disable this feature, delete the registry value [HKLM \ Software \ Microsoft \ Fusion! EnableLog].

--- End of internal check of the exception stack --- at System.RuntimeMethodHandle._InvokeMethodFast (Object target, Object [] arguments, SignatureStruct & sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke (Object obj. , Binder binder, Object [] parameters, CultureInfo culture, Boolean skipVisibilityChecks) to System.Reflection.RuntimeMethodInfo.Invoke (Object obj, BindingFlags invokeAttr, binder, Object [] parameters, CultureInfo culture) to System.RuntimeType.InvokeMember (String name , BindingFlags bindingFlags, Binder binder, Object target, Object [] provided byArgs, 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 libraries and the task script referencing it, built in 3.5. I researched this for a few days but couldn't find anything that could fix it. I have tried to recompile the OpenPop DLL from source and remove and re-add the link several times.

The code I'm 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;

      

Thanks in advance.

+3


source to share


2 answers


I am also experiencing this problem and the solution is actually quite simple. You have to install the referenced assembly in the GAC of the server that is running the package.

1) Make sure the assembly is signed, if you created your own assembly, sign it.

2) Install DLL to GAC using gacutil.exe

from Visual Studio SDK tools. For more information, see How to install an assembly into the global assembly cache .



3) Link to the same DLL from your Script task

Voila, it should work fine now!

+7


source


Installing your DLL in the GAC (global assembly cache)

1) Visual Studio Command Prompt => Run as Administrator

2) gacutil / i "path to dll file"



3) see assembly at C: \ Windows \ system32 \

It will also decide that dll is missing or "Could not load file or assembly" in SSIS Script task

+1


source







All Articles