Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I am lost ... completely!

I have a console application that was working fine a few weeks ago and now, suddenly, I can't get it to work. It uses a web service I built to access some databases which I have confirmed works fine (I use it in several other applications, albeit they're all web-based).

When I call the web service (referenced as dnc2ws):
dnc2ws.dnc2ws dncws = new dnc2ws.dnc2ws();


I get this:
System.Reflection.TargetInvocationException was unhandled
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
       at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type type, String defaultNamespace, XmlSerializerImplementation& contract)
       at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
       at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
       at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
       at BGService.dnc2ws.dnc2ws..ctor() in C:\exco\DNC-2\Prototype\DNC2\BGService\Web References\dnc2ws\Reference.cs:line 124
       at BGService.BGService..ctor() in C:\exco\DNC-2\Prototype\DNC2\BGService\BGService.cs:line 29
       at BGService.Program.Main() in C:\exco\DNC-2\Prototype\DNC2\BGService\Program.cs:line 27
  InnerException: System.Runtime.InteropServices.COMException
       Message=A procedure imported by 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll' could not be loaded.
       Source=BGService.XmlSerializers
       ErrorCode=-2147024769
       StackTrace:
            at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract..ctor()
       InnerException: 


I've tried backing out the changes to the web service that I've done over the last few weeks but that doesn't make a difference. I've confirmed that the web service works (I have a couple web apps consuming it already).

Can someone help me out? I've been at this for days!

Thanx,
Peter
Posted

Do you have any other client accessing the web service? You might want to create a dummy client, add a new reference to the client and try accessing the web server. If that works, try to use that proxy class in your existing client. Based on that you can narrow down on what might be the issue. Also, this might be a bit out of the line, but does your client have enough security to access the web server (though I do not think this might be the issue). The reason that you are getting the error while instantiating the web refernce is puzzling. If it was happening while trying to access a web mthod, it would have been easire.
 
Share this answer
 
Comments
Sandeep Mewara 23-Sep-10 12:05pm    
You can always update your answer!
Peter Scheffler 23-Sep-10 14:43pm    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
It might not have to do with the web service at all. Since you are saying that the web service works fine, it could be due to some other issue. Did you try and check to see if the proxy class got corrupted. You can try and renegerate the proxy and try again. Also, check if any other client is having the same problem with the same proxy class.

Also, are you referencing any assembly from GAC?
 
Share this answer
 
Thanx for the response. I actually deleted the reference to the service completely (and the resulting folders) and reattached it (several times), thinking along the same lines.

As for referencing assemblies from the GAC, I have added a couple items to the project:
XML
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />


Does that help you at all?

Also... I built a complete new virtual machine, thinking maybe I corrupted something in my other environment... so the likelihood of there being a corruption in the GAC would be slim.

I appreciate the help!
 
Share this answer
 
Hi Anshudutta

Thanx for the help... it was an issue of permissions - you were right (I'll mark your answer as such).

The way I have my development virtual machines setup, I have a symbolic link referencing my code within the VM, back to the home server's drives (makes backups easier to track).

But, console apps don't like to run like this, they're expecting things to be on the LOCAL drive (even the mklink command isn't sufficient.)

I've created some test apps on the local VM drive and it works fine.

Man, that's a week wasted on an elusive 'bug'!

Peter
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900