Virtual Interface Method not supported when DLL used by VB6 program - c#

Ok, right to the point here is my background story:
I got a vb6 app that will now retrieve data from SAP
A SAP web services was created
I created a DLL using C# that contains the service reference to the web service, makes the call and creates a XML in an ADO Recordset compatible format.
All these has been successfully tested using a Windows Form
There's no problem yet
Now, that being "said", when I integrate that DLL to VB6 I successfully call the DLL's functions. But when I call the function that will return the XML I got the following error:
Virtual Interface Method >WebServiceObject::urn:sap-com:document:sap:soap:functions:mc-style< not supported
And I received an incomplete XML. However when I make the same call from a .NET test web form I got the full XML and everything looks beautiful.
Any hints on this?

Alright,
After a long day looking for this, frustrated with the idea that all my logic looked good I found that the error was on my part. For all of you getting this error please check that methods, parameter, objects in your WSDL matches you endpoint. My problem was that I am setting the end points programmatically using the endpoint's URL and a different end point address was passed from VB6, hence the error that the method called was not supported since it did not belong to that end point.
Good luck all!

Related

COM export method from object in .exe application [duplicate]

I currently have a .NET class library written in C# that exposes its functionaility via COM to a C++ program (pre-.NET).
We now want to move the library out-of-process to free up address space in the main application (it is an image-processing application, and large images eat up address space). I remember from my VB6 days that one could create an "OLE automation server". The OS would automatically start and stop the server .exe as objects were created/destroyed. This looks like the perfect fit for us: as far as I can see nothing would change in the client except it would call CoCreateInstance with CLSCTX_LOCAL_SERVER instead of CLSCTX_INPROC_SERVER.
How would I create such an out-of-process server in C#? Either there is no information online about it, or my terminology is off/out of date!
You can actually do this in .NET (I've done it before as a proof-of-concept), but it's a bit of work to get everything working right (process lifetime, registration, etc).
Create a new Windows application. In the Main method, call RegistrationServices.RegisterTypeForComClients- this is a managed wrapper around CoRegisterClassObject that takes care of the class factory for you. Pass it the Type of the managed ComVisible class (the one you actually want to create- .NET supplies the class factory automatically) along with RegistrationClassContext.LocalServer and RegistrationConnectionType.SingleUse. Now you have a very basic exe that can be registered as a LocalServer32 for COM activation. You'll still have to work out the lifetime of the process (implement refcounts on the managed objects with constructors/finalizers- when you hit zero, call UnregisterTypeForComClients and exit)- you can't let Main exit until all your objects are dead.
The registration isn't too bad: create a ComRegisterFunction attributed method that adds a LocalServer32 key under HKLM\CLSID(yourclsidhere), whose default value is the path to your exe. Run regasm yourexe.exe /codebase /tlb, and you're good to go.
You could always expose your .NET class as COM classes using InteropServices and then configure the library as a COM+ application. The .NET library would run out-of-process and be hosted by a DLLHOST.EXE instance.
Here is an article in MSDN that covers all aspects of how to create COM localserver in c# (.net): link
Your post started a while ago and I had the same problem. The following link is absolute gold and tells you everything
http://www.andymcm.com/blog/2009/10/managed-dcom-server.html

In C#, how can I get the name of the calling project from within a referenced project?

I have three projects: My.Business, My.WebSite and My.WebService
I need my logging class to be able to identify when a request is made from the website versus the web service. I used to have the web service running as a separate application underneath the web site, so I'd just use different config files, which worked fine. But I want the web service now to run under the same application.
If I could figure out if the request was coming from My.WebSite or My.WebService, I'd be set, but I'm not sure how to do this.
Assembly.GetExecutingAssembly() returns back My.Business
Assembly.GetEntryAssembly() is null
I could check the StackTrace, but that seems sloppy and how for back would I have to go? Especially because the logging may be triggered by code in My.Business that was originally invoked from one of the other projects.
Since the web service requests end in ".asmx", the following concept works, but it just doesn't feel right.
return HttpContext.Current.Request.Path.IndexOf(".asmx") >= 0 ? "My.WebService" : "My.WebSite";
Thanks!
You should be able to use Assembly.GetCallingAssembly():
return Assembly.GetCallingAssembly().FullName;
This will return the assembly that invoked the current executing method, so you can capture whoever is calling into your My.Business assembly that way.
With that said, I tend to agree with the comment above by Meirion Hughes. You might like to consider passing in any info that is required to your logging class, especially if it is likely to be used across more applications in the future.
this.GetType().Assembly.FullName will give you the name of the assembly name for the current class.

Csla DataPortal not finding implemented methods (Silverlight)

I am developing a silverlight application that uses CSLA for the business objects.
I'm trying to set up the DataPortal correctly so that it will correctly call the DataPortal methods that are contained in my .Net class library.
I have my Model and Model.Silverlight projects set so the classes in the silverlight project are created as links and my DataPortal methods are all inside #if !SILVERLIGHT compiler directives. The silverlight UI references the Model.Silverlight project and uses Get methods which then call DataPortal.FetchAsync.
Picture of my project layout here http://i.imgur.com/V3pQppa.jpg
My issue is that FetchAsync returns with the error DataPortal_Fetch not implemented, though the method with the correct signature exists inside the #if !SILVERLIGHT block.
This leads me to believe the data portal is not configured properly. I have the web service created and I can browse to it by right clicking > View in Browser. The web service is also set correctly for Csla.DataPortalClient.WcfProxy.DefaultUrl in the App_Startup. So I honestly do not know what else to try.
Hopefully someone can help as the problem has been plaguing me for days and I can't register on the CSLA forums to post there. Thanks in advance!
It seems like my issue was I was missing this line in the App_Startup
Csla.DataPortal.ProxyTypeName = typeof(Csla.DataPortalClient.WcfProxy).AssemblyQualifiedName;
Which seems to have become needed in CSLA 4.5
Now the data portal is finding the implemented methods correctly

Adding web reference is not generating the expected reference.cs file. Absent functions

I'm working with an old windows app in visual studio 2005. A webserviced referenced in the original app has 2 functions and when i peak inside the auto-generated reference.cs file I notice a couple of other functions to allow async calls have been geenrated i.e. BeginWhateverFunctionNameIsCalled and EndWhateverFunctionNameIsCalled.
My problem is that I've created a new windows app and added the same web references but the Begin and End functions are not generated in my reference.cs proxy class. Anyone know whats going on?
It is VS2005, and isn't generating the async methods. OK; is it .NET 2.0 or .NET 3.0 (via the VS2005/WCF add-on)?. It looks like "wsdl.exe" (the original) will generate "FooAsync" methods, but WCF ("scvutil.exe") may generate the "BeginFoo" pattern. You might also look to see if you have used WSE*, for example, "wsewsdl2.exe" or "wsewsdl3.exe".
My bets would be of the WCF version. Note also that different frameworks (Silverlight etc) have their own proxy generation classes.
First step would be to check wsdl file returned by web service if those methods are still available on the server.

SkillSoft Web Service Issues

Using Visual Studio 2005 and C# .NET I was attempting to call methods from the SkillSoft API through their web service and have been running into issues when creating the instance. I started by adding the web service reference to the project (Add Web Reference) and that works fine. Where I get tripped up is in the main .cs where I wish to call the methods I create an instance with the line of code:
SkillSoftWebService.OlsaService service = new SkillSoftWebService.OlsaService();
When I build and run this I get a CS0029 error: InvalidOperationException and it mentioned implicitly converting the queryInclude type to the queryExclude type. I know this question is specific to only those using Skillsoft but I was wondering if anyone had found a work around to this?
Thank you!
As I stated in my last comment, it was actually an issue with the Web Service provided methods so I was able to work around this generic exception by just removing the offending method (since I didn't need it).

Categories