Is there a way to make a COM or Interop work on IIS Server Deployed ASP.net MVC?
I created an MVC Site which have a reference to a custom maid Interop COM to a scanner machine.
It works on Debug mode on VS but, when I try to deploy it on IIS and access it. It gives me Retrieving the COM class factory for component with CLSID {3FEDB614-C25B-448C-AED3-2D38A6C95765} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
The Thing is, the dll it self is already installed on my Machine, I think it is working on debug mode cause the IIS from VS is running differently or because I have a reference of the DLL needed.
But in IIS Deployment. Error Occurs. Any Ideas?
My main goal here is, to run the site on a Local Network and everyone can communicate with that site that has the Scanner Installed on.
Easy Idea, but hard implementation for me. And I am not even sure, if the call that I am doing is going to be made in the Host, rather than the Client.
Looks like IIS application Bin folder doesn't have Interop dll, copy the Interop dll, it's named as Interop.[YourCom].dll. YourCom is nothing but original COM. So if the COM name is MyCom.dll, so Interop should be Interop.MyCom.dll. If it's working on Debug mode on VS, then it should be available in VS application Bin folder.
Prerequisite of Interop dll: COM should be register in same the system.
It ends up that, Even Registering it Manually, doesn't Help in my case, don't ask I HAVE NO IDEA WHY.
I resolve it by letting the VS studio Project Settings/Build Tab/ Register COM check mark do the Rest. But the trick is to Run VS in Administrator or you will have an error. Last step is right clicking the bin Folder and choosing add to project. Not really sure why it didn't work without it, because I am pretty sure it doesn't need to be in the current project since IIS will redirect anyway in the bin folder.
Interop name is already applied but like Maiti says, it is needed.
Related
I have ASP.Net Core 2.0 MVC app that references several COM objects. I've referenced the COM objects via Visual Studio's Add Reference process. References show in my solution such as
Interop.XYZ
VS automatically set the Embed Interop Types to true, as it's supposed to do.
The solution builds and runs and I can successfully use the methods in these references locally.
When I publish it to IIS on another machine though I get this error:
Retrieving the COM class factory for component with CLSID
{5D9E1092-69D4-11D2-BCBB-0000E82BB3D3} failed due to the following
error: 80040154 Class not registered (Exception from HRESULT:
0x80040154 (REGDB_E_CLASSNOTREG)).
My app pool has Enable 32 Bit Applications set to true. In my Project Properties, Platform target is set to Any CPU (I tried forcing it to x86 and the site won't even run on IIS after publishing).
I made a clone of the app using .Net 4.7 and configured it the same way, using the same COM references, and published to a second site on the same server. The published version of that app works fine so I don't think it's an issue with the assemblies not being registered (should't be in any case since Embed Interop Types is true for all the COM referenes).
Anybody know what's going on?
Not sure of this is related, but there is another question with a similar message and with an answer.
Here is the link:
Link
I have a WPF application, which I build as a dll COM component and install using installshieldLE, however I have some issues with some dependent dlls, when running my COM client.
My WPF dll references two other C# dlls (A & B) which reside within the same VS2012 solution.
My WPF dll has the register for COM interop option checked and provides a COM interface for running the WPF GUI application.
I have a C COM client program, which tests the WPF application. The problem I am having is that I need to include some of dll_A's referenced dlls, (which is a third party graphics package) in the folder of the client program for the application to run successfully. I don't have to include dll_A or dll_B in the local client directory.
Also, there are other (C) dlls referenced by the COM server dll and included in the installation that do not need to be present in the client directory, so this is difficult to understand.
I assume that this is not a WPF question but simply a question about com server installation in relation to other referenced assemblies.
I have output some debug messages in the primary dlls that confirm that the dlls A&B, along with the main COM dll are being run from the installation location. But I get exceptions further down the line when the third party dlls are missing from the local client folder.
Can someone help me troubleshoot this problem please. I can run the client program successfully from the installation location and am therefore certain that all required assemblies and dlls are present.
Thanks.
It sounds like you're encountering issues related to the DLL load path. A client application can load your COM DLL, but your COM DLL can't load its own dependencies (or dependencies of dependencies, etc) even through the dependencies exist in the same folder as the COM DLL. Is this correct?
If so, I believe this problem can be solved with a call to the AddDllDirectory function -- just have your COM DLL call this before loading any of its dependencies and call RemoveDllDirectory when it's done. For more information, see the Remarks section of the documentation for LoadLibrary.
The problem was caused by one of the referenced dlls being compiled using .Net 4.0, whereas the others were compiled using .Net 4.0 client. Recompiling with .Net 4.0 Client resolved the problem.
The problem seemed to occur when executing the application as a registered com component, with the client being executed from a different location. If the offending dlls were copied to the client directory, everything runs fine.
I have a multi-project solution (C#) that I am trying to deploy to one of our test servers. All the projects are being built for x64, with the 'Prefer 32 bit' disabled where applicable.
Some of the projects reference a SQLite dll set that uses the SQLite Encryption Extension (not managed by nuget). When I build and install the solution on my local dev machine, the application and windows service are able to function properly, no problems.
When I try to install the same package on one of our test servers, running 64-bit Windows Server 2012, I get the "Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found." whenever I try to communicate with the SQLite database. I have triple checked that all the appropriate DLLs are in the program folder after installation.
In my VS solution, I have tried creating the x86/x64 folders, setting Copy to Always, but to no avail. I have also copied the DLLs from my local install folder into the server folder just to see if something got messed up along the way.
Could it be a permissions issue? I'm an elevated user but not a full admin on the server, whereas I'm a full admin on my machine. I've tried manually modifying the permissions on the program folder to see if that was an issue, but had no luck with that either.
So to summarize, the project is being explicitly built for x64, it has the right DLLs in the right folders, and it works on a local install. I'm at a loss as to why it won't work on the server install. I've looked through countless threads on StackOverflow, MSDN, and SQLite's website, all usually suggesting the x86/x64 folders, but that hasn't been working for me. I'm hoping someone can help me out here.
Thanks!
Was actually able to figure it out after a bit more debugging. The Visual C++ runtime that was installed on the server wasn't the right version. I added the Merge Module to the installer for the version my project was expecting, reinstalled the app on the server, and now it's working beautifully.
For those who have this issue, look for the right version of the VC++ runtime in C:\Program Files(x86)\Common Files\Merge Modules. If you don't know what version you need, use something like dependency walker on the machine that is throwing the error. Mine told me I was missing VC140, so that's the module I copied into my project and added to the installer.
I have an ASP.NET application, which has two references added: MapServer and GDAL. These two DLL's uses a bunch of other DLL's, and all of them are in my applications /bin directory.
When I run the application on my own PC in Visual Studio 2010 it runs fine. When I upload it to my Windows 2008 server with IIS it throws this exception:
Could not load file or assembly 'gdal_csharp' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
When running the application through Visual Studio on the server it runs fine.
I've even tried adding the /bin directory to the PATH enviroment variable, and restarting the server. No luck though.
My guess is that the DLL is a 32-bit only DLL that you are trying to run in a x64-environment. Can you try to set the app-pool to 32-bit only?
Update: a simple instruction is here: http://help.webcontrolcenter.com/KB/a1114/how-to-enable-a-32-bit-application-pool-in-iis7-dedicatedvps.aspx
You need to register the dll at GAC: http://en.wikipedia.org/wiki/Global_Assembly_Cache
As already mentioned you may be missing something from the GAC.
To see whats happening you could try turning on Fusion Logging, this will enable you to view all of the assembly load failures.
Back to Basics: Using Fusion Log Viewer to Debug Obscure Loader Errors
I'm currently working on a program in C# WPF. I use an external dll called Irrklang. It's made for x86 only so I set VS to compile for x86. I added the reference, set the copy local to true and set the dll as Required in the application files.
When publishing the app using clickonce I upload it. I install on two machines: my dev machine and another machine. On my dev machine things work fine. On the other machine I get the could not load file or assembly exception through my error handling I added to my app. In the event log there is a xamlparse exception.
How can I solve this when everything works fine on my dev machine. I tried Dependencywalker but that doesn't show anything and I made sure the dll is in the folder of the executable. I ask this question again here on stackoverflow, the last time someone made me an empty app with a reference to the dll and he installed it on 3 other machines and it worked fine. I published his app like I did with my own and it shows the exact same problem!
Please help me out
UPDATE: I was thinking about it but your comment beat me to it! :D I program .net 4 Extended and it is set as a prerequisite. VS C# Express 2010.
Well, no specific advice then. It sounds like you just need to some old school trial and error... Whiddle the app down to something that will distribute correctly with ClickOnce and keep adding functionality until it doesn't!