IPC deserialization exception only on recieving data? Sending works fine - c#

I have a problem, which I realy can't get behind.
I have two programms, the communicate throu IPC using BinaryFormatting. I placed the client- and server-class in the same assembly including all classes to transport data.
What I don't understand is why I'm getting a serialization exception with "Assembly not found" when I'm trying to recive an object but sending one works perfect.
So if the IPC client calls a method "Config GetConfig()" that returns my config-class the exception is thrown. When I call a mehtod "SetConfig(Config config)" the config arrives at the IPC-server without any problem.
I've already tried to switch to SoapFormatter instead of Binary and tried working with interface instead of the class. All with the same result. Sending data works fine, getting Data throws the desirialization exception.
Can somebody give me a hint, how I can fix this issue? Or at least what to look for to fix it?

so some time after asking the question I finally found the problem and the solution.
Problem was, that my client is part of a COM-Component and a post directed me the way, that the binaryformatter doesnt care about already loaded assemblies. It looks like it always tries to resolve the assembly from the AppDomain.CurrentDomain.BaseDirectory which is the path of the executable in my case it's outlook.
So the solution was to bind to the AssemblyResolve-Event in the appdomain an resolve the assembly from the correct directory.
Hope this helps if somebody else has the same problems.

Related

SOAP with external namepaces deserializes to NULL

I'm implementing a client to a SOAP-service, which I don't have access to. Since I'm a bit of a newcomer, I really don't have much experience with SOAP, so I went with the default approach of adding the Service Reference via Visual Studio 2017, configuring the Service via config-file and then hope it works.
Unfortunately, whenever I call the service, I get a NULL-response. Searching a bit, it seems like some Namespace problems. In fact, the WSDL has a lot of defined external namespaces, like:
xmlns:eCH-0011="http://www.ech.ch/xmlns/eCH-0011-f/8"
I thought, the proxy generator would take of this, but for example when I use the http://webservicestudio.codeplex.com/, I get a namespace exception like:
Schema parsing error In diesem Schema ist Namespace
'http://www.ech.ch/xmlns/eCH-0044-f/4' nicht für den Verweis
verfügbar.
Which is german and means the namespce is not avaliable for a reference.
I tried to create the WSDL dynamically by calling the service with the "svc?wsdl" prefix as well as received a WSDL from the developers, but both are not working.
I also used Fiddler as proxy, and I see in the response I would get correct XML, but yet, in the code I don't get any error nor other feedback what the problem is.
Is it generally not possible to have external namespaces, or am I configuring something wrong here? I'm currently trying to kindahow sneak between the incomming data and the deserialization, but didn't have any luck so far. Sadly, there are not much information around as far as I seached for it.
Playing around: I played around further, implementing a IClientMessageInspector and a IEndpointBehavior, where I can debug the incoming message. This seems fine, so it has to be the SOAP-formatter, which causes problems here. Unfortunately, I still can't get an Exception, yet it's always null.

SqlConnection exception thrown by WPF but not by WebSite?

I have this project, which consists of a WCF Library acting as a Server for a Trouble Ticket system.
Link for solution skeleton: http://imgur.com/eZqe5Q8
I have an interface that allows me to access the server methods.
I have a DB as you can see in the picture, called "MainDB".
I have a website with a service reference to the server which works perfectly fine.
Then I needed to create a GUI application client that accesses the same server interface. I did this by creating a WPF application. I reference the server, just the same as I did in the website and use the same interface, and I call the exact same method, in this case the Login method, which you can check in this image: http://imgur.com/3PajH3U
But when I call this method from the WPF I get an exception on the red squared line which says this:
"An unhandled exception of type 'System.NullReferenceException' occurred in TTService.dll
Additional information: Object reference not set to an instance of an object."
I thought it might be because of the DB not being "published", but it was. I run the website and the WPF at the same time and one runs perfectly smooth while the other causes that exception. I can't get what's causing this, probably because I'm still not experienced in this technology.
The fact that the origin of the method call is different doesn't seem to me like a plausible cause because I can't understand how the method would know where the call originated.
I'm sorry I can't put the images in the post but not enough reputation yet.
Thank you for any help.
I fixed this. It actually was the Interface implementation that was wrong. Sorry for the misinformation.

Use of Forest.GetCurrentForest in RODC environment

I've got a problem with using Forest.GetCurrentForest() method when communicating with a Read-only domain controller.
The exception thrown is:
System.DirectoryServices.ActiveDirectory.ActiveDirectoryServerDownException: The server is not operational.
Note: Everything works fine when communicating with a RWDC.
Previously, to fix other issues when communicating with a RODC, we had to modify the way we created DirectoryEntry objects, making use of the AuthenticationType.ReadOnlyServer flag. However I've seen (using reflector) that the GetCurrentForest() method creates its own DirectoryEntry object using a Utils class, which in turn uses a DefaultAuthType.
So, my question is: Does anyone know how to set/modify the DefaultAuthType so that it can return the required authentication type? Is there a better way to do this? The aim of this piece of code is simply to get the list of available domains visible to the server.
Thanks,
Ben
Well, doesn't seem like there's an easy answer to this. In the end we rewrote the code to not use the Domain/Forest objects...
What I do to "overcome" this issue was, I first try to get the Forest.GetCurrentForest(), and if exception thrown, I then use Domain.GetComputerDomain() for last solution, of cause, the list now only contain the domain that the web server joined.

ImDisk API issue in .NET

I have been working on implementing ImDisk into my C# project, where I can create RAMDisk on the fly. Unfortunately due to absolutely no examples, I am at a bit lost as to how to resolve this issue.
I am receiving the error Unable to find an entry point named '_ImDiskFindFreeDriveLetter#0' in DLL 'imdisk.cpl'. which, after Google searches, is apparently from not initiating an object. However, ImDiskAPI has no constructors, and cannot be initiated in that manner, so I am at a bit of a stand-still. When I attempt to initialize an instance, I get The type 'LTR.IO.ImDisk.ImDiskAPI' has no constructors defined
Does anyone have any idea what I can do to get this going?
The error indicates that there is a DLL missing.
You need to place the ImDisk.cpl file into your application's directory.
The managed wrapper library needs the ImDisk.cpl file to function properly.
Hope, this helps.

MSMQ not invoking COM

I made a COM object with c# and let VS register it for me. I can see it in registry and if I make a test app I can add a reference to it and it works as expected with all the methods available and functional.
Now If I try and use it in a MSMQ rule nothing happens. It will not be invoked. Is this because it is a .NET assembly? Is it because I do not have VS Pro? Do you have any idea at all?
You haven't by any chance registered your component on a mapped network drive have you? MSMQ runs in a different WinStation to the interactive WinStation. Network drives that are mapped in the interactive WinStation are not visible in other WinStations which could result in the symptom you described (component not found).
You need to check the system event log for error messages (eventvwr.exe). If your component is registered and MSMQ is properly configured to activate your component but it fails, most likely the problem is with permissions. The event log should contain the details of the prolem.
Update!!!
I was messing around with this again. I created a simple EXE to fire when a message is received. It accepts 2 string parameters.
I forgot to pass the parameters the first time and I get the SAME error as I was discribing before. About the COM object not being found. I passed the parameters and it worked fine.
I thought I was passing the parameters to my COM object just fine, but maybe not. Maybe I'm doing something wrong. I will create a COM with no parameters and see if I can force the COM to invoke.
If anyone as examples of creating objects to accept parameters, please let me know.

Categories

Resources