Configuration system failed to initialize from c# com dll - c#

I have com dll written in c# and everything works ok when I use it from the normal exe project in visual basic 6, but when I try to use it from the visual basic 6 dll then I get this error: configuration system failed to initialize. This is a dll, so it don't have any app.config file.
I get this error on this line:
request = (HttpWebRequest)WebRequest.Create(ApiUrl);
where ApiUrl is something like: https://www.api.com/
Anyone knows what can be wrong?
Edit:
Maybe there is something with permissions? The vb6 dll is called from the web service hosted on the iis on the same server.
Edit2:
It must be something with IIS_USER, because when I call the vb6 dll from normal exe project, then works.

The impression I get of your setup is:
You have a client (of some sort) that is connecting to a web service that is written in C#, that is calling a VB6 dll that in turn calls a COM-exposed C# dll?
When I've seen this error in the past, I've had multiple Configuration elements in the *.config file. You will have a *.config file for the main service, so I'd start looking there.
A quick google found this URL which backs what I've found in the past too: http://social.msdn.microsoft.com/Forums/vstudio/en-US/b7603703-3805-4e73-ac6a-755a7c14e722/configuration-system-failed-to-initialize?forum=vbgeneral
(apologies for offering as an answer, I can't add comments due to having <50 rep)

Related

Can't able to refer the hwebcore.dll from C:\Windows\System32\inetsrv\hwebcore.dll to visualstudio2013

I am trying to host MVC web application without IIS in windows8. So i referred this link Host MVC web app without IIS
But i can able to add hwebcore.dll file into visual studio it show error like:
ERROR:
please make sure that the file is accessible and that it is a valid assembly or com component
i referred the below link but nothing worked for me.
I want a solution for this : Please make sure that the file is accessible and that it is a valid assembly or COM component
.dll file not accessible
This dll is not a .NET assembly, that's why you can't add a reference to it. What you can do is invoke its exported functions, like WebCoreActivate and WebCoreShutdown. See the example here: http://blogs.msdn.com/b/carlosag/archive/2008/04/14/hostyourownwebserverusingiis7.aspx

Calling C++ DLLs from ASP.NET 4

I'm trying to call a C++ DLL from ASP.NET 4.0 web application but keep getting a DLL Import error - unable to load library 'Library name'.
I've read a lot of blogs where developers experience the same probem and what seems to be working for most people is adding the path to where the unmanaged DLLs are to the PATH Environment Variable
I've done the same on the server and double, tripple checked that I spalled the path correctly and that the C++ DLLs are in that folder but when I view the application in the browser I'm still getting the same error.I've placed logging in the code and it's definitely coming from the portion of code which calls the unmanaged DLL.
Here is some information on my environment:
Windows Server 2003
IIS 6.0
.NET Framework 4.0
ASP.NET MVC 4.0
C#
On the dev machine it works if I copy the unmamanaged DLLs to C:\Program Files\IIS Express
Tried copying the C++ DLLs to the bin folder but as far as I understand ASP.NET copies the DLLs from the bin folder in inetpub\wwwroot\sitename\bin to a dynamic location when it executes the code but this process excludes the unmanaged DLLs.Any advice on what else I can try?
EDIT:
In terms of the code it's exactly the same as any other interop code,I have a wrapper class where I use DllImport to define all th required function calls and in my code I create a new instance of the wrapper and call the required function.As I mentioned this works fine on the dev machine as long as the C++ DLLs are i the IISExpress folder but when I deploy to the server it throws the above mentioned error:
[DllImport("My3rdparty.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int myfunction(int handle, int* response, int timer);
So after weeks of struggling I came up with a work around.The integration that I was implementing was for credit card processing. Along with the C++ DLLs they also have a compiled configuration file called system.dna and my suspicion is that when you add the folder containing the interop DLLs to the PATH Environment Variables it does not pick up the system.dna file.
As a workaround I created a WCF service which is installed as a Windows Service on the server and I've placed the logic for doing payments into this service and the web application simply talks to the service.I hope this helps other developers who are facing the same issue

Loading Native Managed and C++ DLL within IIS 7 for WCF Project On Runtime

I have WCF service developed in C# for with .NET framework 4.0 for IIS v7. My service using some managed VC++.NET DLL's which internally relies on some native C++ DLL's.
Now I have following options to proceed;
1) Publish all my managed DLL's in GAC (Global Repository)
2) set PATH environment variable, re-start my machine so that IIS (7) server can pick up the changes.
But client does not want both of the above solution because of following reasons;
1) They do not want anything available globally
2) Setting PATH, re-start the machine for every service deployed....NAAAAAH!!!!
So I researched and then I found I can set the environment on runtime, so I added some properties within my Web.config file and thought of appending my environment for each service on runtime. But the problem is that where should I write this peace of code as if I append this code in service class IIS will fail as it will try to resolve all the dependencies but fail as my code is not ran yet.
Now I want, a way to split my code which set up the environment in separate class for each service on startup of the service and called that in the end when we un-deploy.
I am not sure if it is even possible?
P.S Please bare in mind I am new to WCF and .NET stuff.
Your help and comments will be appreciated.
--
SJunejo
If yout don't set the Delay Load Property all referenced unmanaged DLLs will be loaded before your global.asax code is executed, so it's still looking in the wrong place.
You should follow all steps in Option 2b) if you want it to work.

Calling C# from ColdFusion

I've written a .dll in C# to change the permissions on a folder. I also wrote an .exe to test the .dll and it successfully changes the permissions. Now I'm trying to call the .dll from ColdFusion, but I'm getting an error about System/Security/IPermission not being found.
I'm assuming this is an interface in C# that ColdFusion can't find in any of the available assemblies on my system. I've added the System.Security assembly to my References in the C# project. Is there something else I need to do to make sure ColdFusion can find the interface?
Here's how I'm using the .dll:
<cfobject type="dotnet" name="permObj" assembly="#pathToDLLs#CoursePortal.dll" class="CoursePortal.Permissions">
<cfset permObj.revokePermissions(dir, username)>
I never could get it to work. I switched the DLL to an EXE and used <cfexecute> to call it. It's working fine now. The .NET code is called so infrequently it doesn't make much difference that it's a separate app.

AppDomains and licence files

We have a dll which uses a third party component, with embedded licence file (licx). now we are trying to use our dll in a windows service applicaiton, using mulitple appdomains. the code get compiled. but when im running it im getting an error message, saying cannot find the runtime licence.
could someone explain me this. when use the dll in a single domain it works fine. please help.
Thanks.
How are you creating the AppDomain? There is a LicenseFile on AppDomainSetup; are you setting this? I'm not 100% "up" on license files and their use within AppDomains, but that may help a little...
Unfortunately information on this area (license files vs embedded) looks very sparse... you could try copying the embedded resource to a temp file?
If there is some static method/property to set then it is likely that you will have to do this per app domain.
I was under the impression however that licx files were only compiled into the executable project not into dll's.
Thus is your service is being started via a route that is not using the executable which had the license embedded in it then it will not get licensed. If you run the service but do not create multiple app domain's what happens?

Categories