My dll is not working in a project on another pc - c#

I wrote my class library in c#. It uses a couple of nuget packages and another dll downloaded from the Internet (visacomlib.dll) I connect it to another (console) project, this bundle works on my computer.
If you compile the final project, it also works. However, if you transfer the compiled project to another PC, an error appears:
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLID.

I partially solved the problem in the following way:
Be sure to install the NI_visa drivers.
Assembly in Rider did not work. On another PC I get the following error:
Unhandled exception. System.Runtime.InteropServices.COMException (0x80040015) HRESULT = 80040015
at VisaComLib.ResourceManagerClass.Open(String ResourceName, AccessMode mode, Int32 openTimeout, String OptionString)
However, I built the same project with default settings in Visual Studio and everything worked.
If everything turns out so well to make a working assembly in Rider, I will supplement this answer.

Related

Running CodedUI Test From Another Application

I'm planning to run my coded UI test from another project (in same solution). I added a reference of the CUIT project to my winform app project. Also I added these references as well
Microsoft.VisualStudio.TestTools.UITesting.dll
Microsoft.VisualStudio.QualityTools.CodedUITestFramework.dll
Microsoft.VisualStudio.TestTools.UITest.CodeGeneration.dll
Microsoft.VisualStudio.TestTools.UITest.Framework.dll
Microsoft.VisualStudio.TestTools.UITest.Playback.dll
My code is something like this
Playback.Initialize();
TestProject.CodedUITest1 coded = new TestProject.CodedUITest1();
coded.CodedUITestMethod1();
Playback.Cleanup();
However, I get an exception on the Playback.Initialize() call.
this is the message...
"An unhandled exception of type 'Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException' occurred in Microsoft.VisualStudio.TestTools.UITesting.dll"
Someone said that installing Test agent 2010/Test agent10 can solve this error.
I installed MS Visual studio Test Agent 2010, but same error happens.
What am I doing wrong here?
Thanks
I tried to run the test the same way you do and it worked for me.
Below are the reference dlls I have added in my projects
Please make sure you have added all the dlls. In case you are not able to find the dlls, look for them in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies.
If this doesn't work please provide the details of inner exception.
I found an answer to my problem. I found that the message of the inner exception is
"Retrieving the COM class factory for component with CLSID {27876903-E697-4406-BF49-1B8B92CB8735} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."
After digging around I found that I have a 32 bit third party dll which I'm running on my 64-bit machine. The conflict is 64 bit process trying to invoke 32 bit process in 64 bit machine.
The solution is to change the project properties to target to 'X86' machine instead of 'Any'.

Why does using SQLite in Azure Functions give me a DLLNotFoundException?

I'm trying to write a timer-triggered Azure Function that downloads a bunch of data and processes it into a SQLite database. I've written code that does this and runs fine on my own machine. But, the same code in Azure yields a DllNotFoundException, complaining that the system can't load "e_sqlite3."
Here is the full error message (for the inner exception):
Exception while executing function: FnordFunction
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception
while executing function: FnordFunction --->
System.TypeInitializationException : The type initializer for
'SQLite.SQLiteConnection' threw an exception. --->
System.DllNotFoundException : Unable to load DLL 'e_sqlite3': The
specified module could not be found. (Exception from HRESULT:
0x8007007E)
at
SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number()
at
SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number()
at SQLitePCL.raw.SetProvider(ISQLite3Provider imp)
at SQLitePCL.Batteries_V2.Init()
at SQLite.SQLiteConnection..cctor()
End of inner exception
Here are the steps to reproduce:
In Visual Studio 2017, I created an Azure Function project using the latest template.
I added my code files to the project, and edited the "Run" method to call the code.
Using NuGet, I added sqlite-net-pcl, and some other libraries I need. (I've also tried this with EntityFrameworkCore, using SQLite; that didn't work either).
Build
Publish
Run. Failure.
The problem might be that my code is wrong--but it works fine when I just make a console .exe.
The problem might be that VS2017 is not bundling the correct dll for SQLite when it builds. I'm not sure how to fix that. I've seen from other searches that the same error message pops up when the platform target is set to "Any CPU," but changing that to x86 or x64 does not fix the problem.
The problem might be that the SQLite libraries I have tried won't run in the Azure Functions sandbox. If so, are there any simple SQLite libraries that will run in the sandbox?
Thanks in advance...
The problem is that when running in a Function App, native binaries can't be automatically loaded from your bin folder, so it's not finding the DLL.
One way to solve this is to drop it in your D:\home\site\tools folder (e.g. using Kudu Console), as that folder is automatically place on the PATH.

Unable to cast COM object - error: No such interface supported

I've got this annoying issue in here when using a VB6 DLL (AB5COM.dll) in my webAPI project.
All is working fine in my local VS2015. The problem occurs only in my remote IIS 7.5 (Win2008 R2) after deploying the published site.
I'm using this DLL in 2 projects of my solution.
I've tried several things -
Generating interop.AB5COM
Disable embed and copy local
platform change to x86
APP POOL supports 32bit
[assembly: ComVisible(true)]
Adding [Guid("xxxxxxx-xxxxx-xxxxxx-xxxxxx")] as attribute in my class
All was useless. Local VS2015 works, remote IIS7.5 fails with this exception.
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'AB5COM.trxAB5core'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{AF42661C-D369-454A-A005-55D51037166A}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I also can't find which DLL I need to register using regsvr32 since the COM dll isn't published, and the interop cannot be registered.
Would appreciate your help on this.
Thx
Ok, since no answer on this, I had to make some moves...
The remote IIS environment is my TEST server, so I've installed VS2017 with my solution, ran my app (success) and published (success).
So currently I have no issues with this COM DLL which brings the conclusion that this is a pure REGISTRY issue. The VS2015 knows how to register the correct DLL and then all works perfectly.
Now, I need to figure how to make this working on my Production...
Although this is NOT a proper solution, I hope my personal post helps anyone.

Getting error on using Skype4ComLib

Hi I am using Skype4ComLib to retrieve Skype contacts but I am getting error:
Retrieving the COM class factory for component with CLSID
{830690FC-BF2F-47A6-AC2D-330BCB402664} failed due to the following
error: 80040154 Class not registered (Exception from HRESULT:
0x80040154 (REGDB_E_CLASSNOTREG)).
Skype is installed on my machine.
any idea?
I recently experienced the exact same error message, and it was simply as a result of my .NET project being compiled for "Any CPU" by default.
The SKYPE4COM library is a 32bit only binary, and as such you should make sure that the project you intend to use it with is specifically compiled for "x86" architecture.
As soon as I did this, the error message just went away.
Simply right-click on your project and select "properties". Then under the "Build" tab, choose "x86" where it says "platform target". This process may vary with your version of Visual Studio, but is correct as of version 2012.
Have you registered the DLL? Take a look at this Blog
From above blog:
In the command prompt type : regsvr32 Skype4COM.dll or "regsvr32
C:\Program Files\Common Files\Skype\Skype4COM.dll"
Also try taking a look at this SO Question

Can not reference a Dll that worked earlier

I am trying to change the Terminal Services settings programmaticly. I learned that you must use tsuserex.dll. Being c# i ran tsuserex through tlbimp and created TSUSEREXLib.dll then registered it with regasm. I got it working and wrote a framework program with it as a prof of concept. However today after I made some changes when I run my program I get the error
Unable to cast COM object of type 'System.__ComObject' to interface type 'TSUSEREXLib.IADsTSUserEx'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C4930E79-2989-4462-8A60-2FCF2F2955EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
it thows the exception on the line
IADsTSUserEx iad = (IADsTSUserEx)((DirectoryEntry)user.GetUnderlyingObject()).NativeObject;
This exact line worked fine in the test project. I know user is a valid UserPrincipal, Googleing I found this is usually just needs the dll re-registered, but even after unloading and reloading it it still will not work. What am I missing to cause my dll to stop working.
I know this is an old thread but since I had trouble recently finding all the required steps to get the Terminal Services components working on Windows 7, I wanted to share what I found. I think the steps below are more reliable than copying the tsuserex.dll from a server and trying to register it.
From what I understand, on any operating system you need Remote Server Administration Tools (RSAT) installed in order to modify Terminal Services attributes of a user account programmatically. On some versions of Windows this requires a download. But on Windows 7, RSAT is already installed.
But you may need to enable it using the configuration options in Control Panel (appwiz.cpl). Under "Turn Windows features on or off" goto "Remote Server Administration Tools" then ensure that "Remote Desktop Services Tools" is checked.
After I did this (and rebooted) I was able to use the components from tsuserex.dll via PowerShell (e.g., Set-QADUser -Identity testUser -TsHomeDirectory "c:\tshome"), and by adding a reference in Visual Studio 2010 (to "tsexusrm 1.0 Type Library").
You almost certainly need to re-register your TLB on the target machine. What likely happened is you have your assembly, interface or type GUID not hard coded in the application and hence it's changed on every rebuild. So after rebuilding and deploying your type no longer matches up with the previously registered TLB.
The correct answer is that I am a idiot for not reliseing that my build environment did change. I moved to a new workstaion that was windows 7 corprate instead of server 2003 when i started on the project. Win7 corp does not have tsuserex.dll in its system.
Visual Studio Build Setting „Platform target“ disable=> “Prefer 32-bit” solve the Problem.

Categories