WCF Async method works on Windows 7 host, but throws signature Exception on XP machine - wcf

My code (target framework 4.0, x86 architecture) works on several Windows 7 machines (both client and server) but throws an Invalid Async Begin method signature Exception on Windows Xp (same .NET framework version) specifying that a method requires IAsyncResult as result type and a callback method.
Actually, my methods use successfully Task<GenericType> as return type and I'm wondering why it fails only on XP hosts.
Example of service contract:
[OperationContract(AsyncPattern = true)]
Task<GetServerConfigurationResult> GetServerConfigurationAsync(string clientID);
Note: I hope there's a smarter solution than refactoring.

Related

Unable to read data from the transport connection VB6 calling com visible c# library

I have a c# Framework 4.7.2 Com visible library that calls a web api.
Unit tests in the VS2017 C# IDE library work fine.
However if I try to call via VB6 I get
System.IO.IOException unable to read data from the transport connection: An existing connection was forcibly closed by the rempte
host.
System.Net.Sockets.SocketException
I am running Windows 10
I call as administrator
C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm /codebase /verbose /tlb:SBD.ComBridge.tlb C:\dev\SBD.ComBridge.dll
to create the .dll and .tlb
I also tried running regasm from the VS2017 command prompt as administrator
RegAsm reports that the libraries register successfully.
In Vb6 the (simplified) code is
Dim o As SBD_ComBridge.BridgeImplementation
Set o = New dBridgeImplementation
o.SetOrderDates id
set o = nothing
In BridgeImplementation the (simplified) code is
[DispId(25)]
[ComVisible(true)]
public void SetOrderDates(int Id)
{
PackAndSend.SetReadByInfo(Id) // calls freight service
}
I know that the code calling the service from within SetReadyByInfo works because my unit test passes when I run it in VS2017
Unfortunately I have been asked not to post the code. However I know that the vb6 code calls Com correctly because there are other methods I call without errors.
I had a similar issue with MYOB api and TLS the solution was to upgrade the Framework. However I can't upgrade the VB6 framework ( the large re-write is not an option) Probably I will just make a .Exe and shell out to it.
[Update]
The link Simon Mourier gave me solves it.
If I add
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
then my com call works on VB6
As the link points out,
This isn't a good solution since it hard codes what TLS version to
use, so it wouldn't use TLS 1.3 in future
As per the update section at the bottom of my question, a work around is to include
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
I need to investigate further for a more complete solution

How To Reference a Com Object in a WCF Service

I need to reference a Com DLL from within a Silverlight program. Since this is not allowed, I created a wcf service and put my reference to the Com in it.
This idea seems to work fine when I ran my wcf service from my local machine but when I publish the service to my server it failed to work. The error was “Object reference not set to an instance of an object” where I tried to instance the DLL.
Here problem line is
m_cloVB6Encryption = New VB6Encryption.cEncryption
VB6Encryption is a complicated one. It called another DLL which calls several others.
To try to isolate the problem I created a very simple VB6 component, this time I got the error
"Retrieving the COM class factory for component with CLSID {74FE605A-5861-41A0-BA13-27DDD9C2EBB8} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."
This is despite the fact that I manually registered the component and it was successful.
The problem line was cloSimple = New Simple.cSimple.
My computer runs Windows 7; the server runs Windows Server 2012 R2 Standard.
Presumably your COM component was build as 32bit...so when you register it is registered as a (InProc) 32bit COM component....(and can only be loaded by a 32bit application).
Your ASP.NET Website is most likely running in an AppPool that is set to be 64bit...thus it can't use the 32bit COM class.
There are 2 options (the clearest and easiest is option 1):
1) Get your IIS WebSite/Application to run as 32bit, so it can access your already registered 32bit COM component.
To make sure your website is running as 32bit too (instead of as 64bit)...change the DefaultAppPool to enable 32bit applications (or you can create a new AppPool which is 32bit specifically for that webservice/site and make it use it...if you don't want to affect other sites).
https://help.webcontrolcenter.com/kb/a1114/how-to-enable-32-bit-application-pool-iis-7-dedicatedvps.aspx
OR
2) Do some additional registration so that your COM class is available to 64bit clients too (you register it so it is run OUT OF PROCESS...so it can be consumed by either 32bit or 64bit clients....but you might not want that for perf reasons...and it might not always be possible)
http://www.gfi.com/blog/32bit-object-64bit-environment/

Unable to cast COM object of type 'FAXCOMEXLib.FaxServerClass'

Hi All,
I have created a Dotnet Application using Dotnet 4.0 Programming language as VB.Net4.0. I have a Windows Service which sends out Fax Document using FaxComexLib Com Component, i have its Inetrop.FaxComexLib.dll, it works great in Windows 7 and Window 2008 Server, i can send out Faxes without any problems.
I have a Legacy Client which Windows XP home with ServicePack3 , i installed my WindowsService there and the Service Works fine other than communicationg with the FaxComexLib Com Component. I tried Several Possible solutions, i copied the the Registry entry({571CED0F-5609-4F40-9176-547E3A72CA7C}) from windows 7 to windows XP, Still no luck
Here is my exception:
System.InvalidCastException: Unable to cast COM object of type 'FAXCOMEXLib.FaxServerClass'
to interface type 'FAXCOMEXLib.IFaxServer2'.
This operation failed because the QueryInterface call on the COM component for the interface with IID '{571CED0F-5609-4F40-9176-547E3A72CA7C}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease)
at FAXCOMEXLib.FaxServerClass.Connect(String bstrServerName)
Any Solutions for this would be greatly appeciated.
Thanks In advance
Suresh
It's been a looong time since I used FaxComExLib, but if memory serves, you need to install the Fax printer or something for XP, it is not installed by default.

error while consuming WCF service from VB6 script

I got a simple WCF service written in C#. I need to consume the service from VB script using MS SOAP Toolkit 3.0. I wrote a simple client code like that:
Dim client
Set client = CreateObject("MSSOAP.SoapClient30")
client.MSSoapInit "http://localhost:8888/MyService.svc?wsdl"
I am hosting my service on IIS 7.5 (Windows 7). The error shows up during .MSSoapInit invocation:
HRESULT=0x1: result 0x1 incorrect function.
- WSDLReader:Could not find '/definitions/service' inside the 'default' namespace of the wsdl file HRESULT=0x80070057: The parameter is incorrect.
WSDLReader:Analyzing the WSDL file failed HRESULT=0x80070057: The parameter is incorrect.
Client:One of the parameters supplied is invalid. HRESULT=0x80070057: The parameter is incorrect.
If i run project from Visual Studio (ASP.NET development server) i don't have any troubles, i can consume service from my client code. Generated wsdl-schemas are equal for both cases (except the port number)
What could be a reason of this behaviour?

MethodAccessException on AuthenticationBase<User>.UpdateUser Exception

I'm calling a UpdateUser on AuthenticationBase class in the System.ServiceModel.DomainServices.Server assembly installed by the WCF RIA Services installer. This works on my Win 7 desktop but on my Win 7 laptop, I get the following exception.
Any ideas on what I ought to be looking for or how I can determine what is different between the two systems? Thanks.
System.MethodAccessException was unhandled
Message=Attempt by method 'System.ServiceModel.DomainServices.Server.ApplicationServices.AuthenticationBase`1<T>.IsReadOnly(System.Reflection.PropertyInfo)' to access method 'System.Linq.Enumerable.Cast<System.ComponentModel.DataAnnotations.EditableAttribute>(System.Collections.IEnumerable)' failed.
Source=System.ServiceModel.DomainServices.Server
StackTrace:
at System.ServiceModel.DomainServices.Server.ApplicationServices.AuthenticationBase`1.IsReadOnly(PropertyInfo propertyInfo)
at System.ServiceModel.DomainServices.Server.ApplicationServices.AuthenticationBase`1.UpdateProfile(T user)
at System.ServiceModel.DomainServices.Server.ApplicationServices.AuthenticationBase`1.UpdateUserCore(T user)
at System.ServiceModel.DomainServices.Server.ApplicationServices.AuthenticationBase`1.UpdateUser(T user)
It sounds like you do not have Reflection permission on the laptop instance.
Are you perhaps running it under another user account?
Have a look at the MethodAccessException docs.
Also, make sure both are running the same version of .NET as there are security changes introduced in .NET 4.