Broken Reference.vb generated after update to VS2012 - vb.net

In my WCF service I have the following OperationContract:
<OperationContract()>
Function getResults(ByVal Settings As Dictionary(Of String, String)) As IO.Stream
...and MessageContract:
<MessageContract()>
Public Class FI
Implements IDisposable
<MessageHeader(MustUnderstand:=True)_
Public id as Integer
<MessageHeader(MustUnderstand:=True)_
Public token as String
<MessageHeader(MustUnderstand:=True)_
Public length as Long
<MessageHeader(MustUnderstand:=True)_
Public del as Char
<MessageHeader(Order:=1)_
Public stream as System.IO.Stream`
Public Sub Dispose() Implements IDisposable.Dispose
FI.Close()
FI=Nothing
End Sub
End Class
On the client side after configuring the service in VS and updating I get multiple errors:
1) For getResults: Instead of the Dictionary an ArrayOfKeyValueOfstringstringKeyValueOfstringstring is expected. I already declared the operation contract as <OperationContract(), ServiceKnownType(GetType(Dictionary(Of String, String)))> without success. My client settings are CollectionType = Generic.List and DictionaryCollectionType = Generic.Dictionary. I also tried deleting and adding the service again.
2) For FI: The method signature that uses the MessageContract FI expects the parameter del to be of type Integer. Here I have no idea what to do.
I have to add, that everything was working fine until recently, the only change I can remember is updating Visual Studio from 2010 to 2012.

I just found out that the underlying problem was an update to .NET 4.5. That's what I did on the machine running VS2010 where the generation used to work. Downgrading to .NET 4.0 did the trick. The generation from within VS is working again.
In conclusion: not a problem of the VS version but of the .NET version of the machine where VS is executed. I guess that the svcutil (or whatever resource the "Update Service Reference" function in VS uses) contained in .NET 4.5 is responsible for the bug.

Related

VB.NET Connected SAP WSDL Preventing Solution from building

I'm trying to build a .NET Class Library that utilises a SAP generated WSDL.
In the reference.vb file that one of the WSDLs generates, I'm getting the following error in this line:
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, Order:=0)> _
With the error being BC30369 Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class. on System.
This only occurs within one of the generated Partial Public Classes that it generates, and not the rest.
After removing System it works:
'''
<System.Xml.Serialization.XmlElementAttribute(Form:=Xml.Schema.XmlSchemaForm.Unqualified)>
Public Property MESSAGE_V4() As String
Get
Return Me.mESSAGE_V4Field
End Get
Set
Me.mESSAGE_V4Field = Value
End Set
End Property

Consuming WCF return value of List(Of String) in WinForms

I've just started to get rid of Web Services and implement WCF instead. But once I tried to add the following method with a List(Of String) return value, my WCF ServiceReference - which was added successfully - had became unreadable in my WinForms client application code. i.e. It was not defined.
The scenario is pretty simple:
I am creating an OperationContract named ServerMessages with a list of string return value.
This is the interface:
<ServiceContract()>
Public Interface ICommunicationHandler
<OperationContract()>
Function ServerMessages() As List(Of String)
End Interface
And there is the implementation class:
Public Class CommunicationHandler
Implements ICommunicationHandler
Public Function ServerMessages() As List(Of String) _
Implements ICommunicationHandler.ServerMessages
Dim messages As New List(Of String)
messages.Add("First Message")
messages.Add("Second Message")
Return messages
End Function
End Class
There is my client application code:
Dim locServ As New LocalReference.CommunicationHandlerClient
TextBox1.Text += "First Server Messages:" & vbLf & locaServ.ServerMessages(0)
I've tried removing the service reference from the project and re-adding it, but this doesn't solved the problem. On the other hand, removing that specific method ServerMessages() makes the ServiceReference available again in my code. I've even tried to define the type List(Of String) in the Service Interface by adding this attribute:
<ServiceKnownType(GetType(List(Of String)), ServiceContract()>
but nothing had changed.
EDIT
I've noticed this warning in the client application Error window:
Warning 2 Custom tool warning: Cannot import wsdl:port Detail: There
was an error importing a wsdl:binding that the wsdl:port is dependent
on. XPath to wsdl:binding:
//wsdl:definitions[#targetNamespace='http://tempuri.org/']/wsdl:binding[#name='BasicHttpBinding_ICommunicationHandler']
XPath to Error Source:
//wsdl:definitions[#targetNamespace='http://tempuri.org/']/wsdl:service[#name='CommunicationHandler']/wsdl:port[#name='BasicHttpBinding_ICommunicationHandler'] D:\WCTApp\Service
References\LocalReference\Reference.svcmap
Thanks in advance.
My problem was solved by unchecking the [Reuse types in referenced assemblies] in the WCF ServiceReference configuration of my client application. Thanks Steve for letting me having another check on it.
The problem - in this case - was that I've added some references in the service (Google Drive references) which was not defined in my application and therefore causing the ServiceReference not to read the service appropriately. Since I decided not to use these references, I should had eliminated them both from my client application as well as the WCF Service. Now that I stopped using these references in my client application, everything worked as it is supposed to be.
This was my mistake but maybe someone else will fall into the exact same issue and find this situation helpful.

VS: Update Service Reference creates requirement for "Global" prefixes in Reference.vb

VB 2012
WCF & EF 6.1*
I have a client and a web service. When I recompile/change the WS, I go back to my client, and 'Update Service Reference'. Works like a charm-except, the resulting Reference.vb in the client complains that any classes that were defined from the server have a Global. prefix; To be precise, the error description is:
Error 9 Type 'serverNamespace.CountryName' is not defined.
C:\...\UpdateServiceReference\Reference.vb
...where UpdateServiceReference is the client side proxy.
Public Interface IUpdateService
[...]
<System.ServiceModel.OperationContractAttribute(Action:="http://...", ReplyAction:="http://.../IUpdateService/GetClientCountriesResponse")> _
Function GetClientCountries(ByVal placeHolder As Boolean) As serverNamespace.CountryName()
[...]
End Interface
This service reference/proxy on the client only imports from system stuff and the server's namespace's entities. My only settings/imports at the top of the compiler-created Reference.vb are:
Option Strict On
Option Explicit On
Imports System
Imports System.Runtime.Serialization
But here is the really strange (well, confusing) part. In order to clear out the generated errors in the Error List:
Type 'serverNamespace.CountryName' is not defined. Change 'serverNamespace.CountryName' to
'Global.serverNamespace.CountryName'.
I need to do as the compiler suggests above, and change (in Reference.vb) any line with something like this:
Function GetClientCountries(ByVal placeHolder As Boolean) As serverNamespace.CountryName()
...to...
Function GetClientCountries(ByVal placeHolder As Boolean) As Global.serverNamespace.CountryName()
---at EVERY place in both class body & interface... And everything works!
How can I decorate my Web Service to just make it work?
I've already tried using all kinds of "Imports" in the WS code, but nothing has any effect... And just stupidly adding a Global prefix to the existing WS code won't compile...

QBFC WCF Service Error

I have a new blank Wcf Service in vs.net 2013 express. I have added the reference to the qbfc12.dll and did the import Imports QBFC12Lib. I run the blank wcf service and it works fine. I then add one line of code and it breaks and gives me a error.
Function that works fine:
Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData
Return String.Format("You entered: {0}", value)
End Function
Function that gives exception(One line of code added only):
Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData
Dim SessionManager As New QBSessionManager
Return String.Format("You entered: {0}", value)
End Function
I get the following exception on that line:
An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code
Additional information: Retrieving the COM class factory for component with CLSID {C693D8F1-180B-4F82-B735-8F511B566718} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Can anyone please help me? I have a wcf server written on my laptop, that runs perfect. I am only trying to move it to my production server, but does not work. So removed all the code down to this one line of code that is giving the issue, but it all worked fine on my laptop.
The QBFC12 installer needs to be run on the machine your application is executing from. It is available for download in the link below. You have to sign up to download the installer, but there's no cost and you don't even have to verify your email.
Page with all installers:
https://developer.intuit.com/docs/0200_quickbooks_desktop/0400_tools/quickbooks_desktop/download_the_sdk
Installer in question:
QBFC12_Installer (Version 12.0.0.29)
https://developer.intuit.com/Downloads/Restricted?filename=qbfc12_0installer.exe

System.Security.HostProtectionException when calling webservice from with a function

I'm getting the following error when calling a webservice from a function.
I have referenced all the required assemblies in sql server with "unsafe" permission set and have registered the project assembly with "external access" and the serializer assembly with "safe" permission sets. I have also looked into the code and I don't see anything like message popup etc...that would be irrelevant in sql server's context. I have created another console app that uses the same service and it can access the service just fine from the same server. What else could be causing this issue? Any help is appreciated.
Error: System.Security.HostProtectionException: Attempted to perform an operation that was forbidden by the CLR host. at System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(Type contractType, Type serviceType, Object serviceImplementation) at System.ServiceModel.ChannelFactory1.CreateDescription() at System.ServiceModel.ChannelFactory.InitializeEndpoint(Binding binding, EndpointAddress address) at System.ServiceModel.ChannelFactory1..ctor(Binding binding, EndpointAddress remoteAddress) at System.ServiceModel.ClientBase`1..ctor(Binding binding, EndpointAddress remoteAddress) at MWMInterfaceBeanServiceClient.MWMInterfaceBeanServiceClient..ctor(Binding binding, EndpointAddress remoteAddress) at MWMInterfaceBeanServiceClient.MWMServiceClient.GetClient() at MWMInterfaceBeanServiceClient.MWMServiceClient.UpdateMobileCrew(Boolean active, Boolean available, Boolean availForOp, String contract, String code, String name, Int32 number, String crewCenter, String crewGroup, String crewId, Int32 crewSize, String crewSupervisor, String crewType, Boolean mdtCrew, SqlXml members, String district, String division, String serviceArea, String mobileNum, String pagerNum, Boolean tempFlag, SqlXml vehicles) The protected resources (only available with full trust) were: All The demanded resources were: Synchronization, ExternalThreading
so, I marked the assemblies as UNSAFE and that made this error go away but gave me another error that said it wasn't able to serialize one of the proxies generated by svcutil to make the request. I already had the serializer assembly generated using sgen in a post build task and registered as UNSAFE and it seems that didn't work. Maybe this only works for simple methods with native types? Therefore, I resorted to a different method mentioned in the following link.
http://www.vishalseth.com/post/2009/12/22/Call-a-webservice-from-TSQL-(Stored-Procedure)-using-MSXML.aspx