Failed to generte code for the Service reference + WCF - wcf

I am getting the following error :
Error 1 Reference.svcmap: Failed to generate code for the service reference 'ServiceReference'. Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Referenced type 'KWI.CLUE.Auto.DataContracts.CLUEResult, KWI.CLUE.Auto.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' with data contract name 'CLUEResult' in namespace 'http://schemas.datacontract.org/2004/07/KWI.CLUE.Auto.DataContracts' cannot be used since it does not match imported DataContract. Need to exclude this type from referenced types.
In order to resolve this issue : In the Configure Service Reference, clicked the Advanced button. Then chose "Reuse types in specified referenced assemblies". And unchecked KWI.CLUE.Auto.Contracts.
Now it works fine but when I am trying to access the client as below :
ServiceReference.CPServiceClient clueProcessingClient = new ServiceReference.CPServiceClient();
I am not able to see the methods of KWI.CLUE.Auto.Contracts. which is the correct behaviour.
Now is there another way to resolve this issue other than what I did.
Thanks in advance
BB

Related

WCF Service Reference Error in WIndows Service

I have a windows service with a base namespace of XXXX. I have a number of WCF services with a base namespace of WebServices. These are hosted in IIS.
When I add one of the WCF services (DataManagement) as a service reference to my windows service, I get the following errors when I build the service:
Error 162 The type name 'WebServices' does not exist in the type 'XXXX.XXXX'
Reference.cs Line 200 Col 61
Error 163 The type name 'WebServices' does not exist in the type 'XXXX.XXXX'
Reference.cs Line 205 Col 94
Error 164 The type name 'WebServices' does not exist in the type 'XXXX.XXXX'
Reference.cs Line 205 Col 134
Reference.cs is an automatically generated file, The lines of code created are:
Error 1:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface IDataManagementChannel : XXXX.WebServices.IDataManagement, System.ServiceModel.IClientChannel {
}
Errors 2 & 3:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class DataManagementClient : System.ServiceModel.ClientBase<XXXX.WebServices.IDataManagement>, XXXX.WebServices.IDataManagement {
I have been struggling to resolve these without much success. None of the suggestions I have found that appear to be related to this issue work for me. There was one issue with the same problem, but there were no answers. Any ideas?
I'm pretty certain your issue is as demonstrated by the following code
namespace XXXX
{
class XXXX
{
}
}
namespace XXXX.WebServices
{
class A
{
}
class B : XXXX.WebServices.A // compiler error : CS0426 The type name 'WebServices' does not exist in the type 'XXXX'
{
}
}
The compiler is attempting to find a nested type within the class XXXX called WebServices and not the XXXX.WebServices namespace hence the error "does not exist in the type".
You can be explicit about the fact that you're referring to a namespace by prefixing the namespace with global::. It's not ideal to do this on a generated file like Reference.cs. If possible maybe consider generating your proxy in a different namespace.
See the help for compiler error CS0426 here
A bit late, but in case someone stumbles upon this...
Steps to reproduce:
Create a windows service project "TestService".
Rename the Service1 class to TestService.
Compile - it works.
Add reference to a WCF service.
Compile - it no longer works.
error CS0426: The type name 'SomeWCFService' does not exist in the type 'TestService'
Solution: Change the name of the TestService class to something else, as it conflicts with the TestService namespace.

MSFlexGridLib Allow User Resize Settings error

After converting VB 2008 project to VB 2012, how to fix the error regarding the MSFlexGridLib, The error says:
Reference required to assembly 'Interop.MSFlexGridLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' containing the type 'MSFlexGridLib.AllowUserResizeSetting'. Add one to your project
The blue line for error occured on the '.AllowUserResizing'
.AllowUserResizing = MSFlexGridLib.AllowUserResizeSettings.flexResizeColumns
Go to your project's properties, select add reference, in COM find Microsoft FlexGrid Control and select it to add it as reference.

The server encountered an error processing the request. See server logs for more details

I have a simple problem.
I've created a WCF Data Service 5.6 in visual studio 2013, and in its *.svc.cs file, modified line
public class CustomdataService : DataService< /* TODO: put your data source class name here */ >
to connect my entities
public class CustomdataService : DataService< SchedulerEntities >
But when I want to see the service in browser it gives me following error
Request Error
The server encountered an error processing the request. See server logs for more details.
The entity framework is nothing but a single table...
The actual error can be different. In my case I got the same general error message when starting with AdventureWorks2012 database.
So the actual problem can be seen by appending an attribute to the service class as described at here:
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class WcfDataServiceAW : EntityFrameworkDataService<AdventureWorks2012Entities> { ... }
Hope it helps someone.
PS. My error is:
The exception message is 'The property 'SpatialLocation' on type 'Address' is of type 'Geography' which is not a supported primitive type.'.
It seems that Entity Framework 6 and WCF Data Services 5.6.0 need some provider to work together, read more on Using WCF Data Services 5.6.0 with Entity Framework 6+.
You can download the provider simply by using NuGet Package Console Manager:
Install-Package Microsoft.OData.EntityFrameworkProvider -Pre
Its version is alpha 2, so in future, search for final release. it worked for me however.
Final thing is, instead of using DataService<T>, you need to use EntityFrameworkDataService<T>. T is the name of your entities.
According to this post, you have to change inherited type of CustomdataService.
Replace the base type of your DataService. For EF 5 or below, your data service should inherit from DataService where T is a DbContext or ObjectContext. For EF 6 or greater, your data service should inherit from EntityFrameworkDataService where T is a DbContext. See What’s the difference between DataService and EntityFrameworkDataService below for more details.
go to edmx, in the diagram, remove all the tables until the only one you want is remain,
then should be okay, cannot have all the tables, this is what I found,
KT Wong

Use a C++/CLI DLL using afxwinforms.h as Reference of another C++/CLI DLL also using afxwinforms.h

In Visual C++ 2010 i added a reference from a C++/CLI DLL (ControlWrapper.dll) to another C++/CLI DLL (CliLibrary.dll).
Both are including afxwinforms.h in the stdafx.h.
When i try to compile i get these errors:
error C2011: 'Microsoft::VisualC::MFC::CWin32Window' : 'class' type redefinition
error C2011: 'Microsoft::VisualC::MFC::CWinFormsEventsHelper' : 'class' type redefinition
If i turn of the Option Reference Assembly Output and add #using "CliLibrary.dll" to the using .cpp File i get the following warnings:
1>ControlWrapper.dll : warning C4944: 'CWin32Window' : cannot import symbol from 'c:\dev\trunk\CliLibrary.dll': as 'Microsoft::VisualC::MFC::CWin32Window' already exists in the current scope
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwinforms.h(83) : see declaration of 'Microsoft::VisualC::MFC::CWin32Window'
1> This diagnostic occurred while importing type 'Microsoft.VisualC.MFC.CWin32Window' from assembly 'CliLibrary, Version=1.0.4843.17337, Culture=neutral, PublicKeyToken=null'.
1>ControlWrapper.dll : warning C4944: 'CWinFormsEventsHelper' : cannot import symbol from 'c:\dev\sfirm\trunk\sfclrlib\debug\sfclrlib.dll': as 'Microsoft::VisualC::MFC::CWinFormsEventsHelper' already exists in the current scope
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwinforms.h(122) : see declaration of 'Microsoft::VisualC::MFC::CWinFormsEventsHelper'
1> This diagnostic occurred while importing type 'Microsoft.VisualC.MFC.CWinFormsEventsHelper' from assembly 'CliLibrary, Version=1.0.4843.17337, Culture=neutral, PublicKeyToken=null'.
How could i solve the error?
Well, this is a painful problem. It certainly explains why you are the first programmer I ever encountered that actually uses this. The problem is caused by this declaration in afxwinforms.h:
public ref class CWin32Window : public System::Windows::Forms::IWin32Window
// etc..
The public keyword is the killer, that adds the class to the manifest of your assembly. So when you reference it in another project that also includes the header then there are two definitions of the class. The mix of both native and managed classes in that header prevents a clean solution.
I think you already found the best solution, using the #include, with #pragma comment(disable:4944) to shutup the compiler. Including the header inside a namespace might be another viable hack, it renames the namespace of CWin32Window, but I'd expect trouble when linking mfcm90.lib. Restructuring your solution and keeping all winforms code inside one project is the only thing I can recommend.
Are you using the types in afxwinforms.h?
If not (like in my case), the solution is to comment the include and add this two lines:
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
or add a reference to that two assemblies in your Project.

MetaData Problem: SymmetricSecurityBindingElement

I am figuring out someone else's code and I am trying to generate a proxy out of one of the services and it generates the following error...
System.InvalidOperationException: An exception was thrown in a call to a policy export extension. Extension: System.ServiceModel.Channels.SymmetricSecurityBindingElement Error: Specified argument was out of the range of valid values. Parameter name: parameters ----> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Can anyone direct me in the right direction. how can I solve the problem?
Its just a configuration issue. It means the Service is not configured correctly.