Adding a WCF Service (<> WCF Service Reference) gives "Specified Cast is Invalid" - wcf

When adding a second WCF service to an existing WCF project, or adding a first WCF service to a project gives me a dialog box "Specified Cast Is Invalid". WCF files are added to the project except interface file. Web.Config isn't updated neither.
I think the problem started after updating VS.NET 2008 to VS.NET 2008 SP1.

You can always reinstall SP1 if you are uncertain about the installation. A successfully install SP1 should not cause this problem.
When we have had problems adding WCF references there have generally been on of the following problems:
Data contracts incorrectly specified, missing a tag [Datamember], [DataContract]...
Is your Interface marked as public?
If you are referencing a DLL with types from both the client and the server, is everything serializable and public. Are you using the same version of the dll on both sides?
Is your contract very large? You may need to increase the buffer sizes to get the information to build the proxy.

Related

Could not load file or assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies

I am getting this error in a WCF web service when the program attempts to use a method that employs the entity framework. However, we know that the server has the entity framework (correct version) installed because it is hosting another WCF web service and an intranet site that use it successfully.
I've tried to set copy local to true, however this simply compiles the Entity Framework dll into the debug/release folder of the project that uses it, not the web service project that gets deployed (the project that gets deployed contains a references the project that uses the entity framework).
Has anyone run into this kind of issue before and know a work-around either with or without using copy local?
The solution to this problem was to simply place the EntityFramework.dll and .xml file generated in the bin of the project that uses the Entity Framework and place that in the bin of the service project that was being deployed.
Check to see that the Application Pool for the IIS Site in question is set to use to correct .NET Framework version. In the case of EF 4.1, the Application Pool should be running on .NET Framework version 4 or higher.
To identify the version of .NET being used by the site, first find out the Application pool in use (in IIS, click on Basic Settings for the site), then identify the appropriate pool under the Application Pools node. The .NET Framework version should be listed.
Check whether bit versions are compatible between entity framework and server. If the server is 64 bit and you are using 32 bit entity framework dll you can get this error. Then change app pool setting to enable 32 bit applications.

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154

I am running 32 bit Windows 7 Operation System which has IIS 7.5 installed.
In Visual Studio 2010, I open my solution having the web site project hosting WCF service. I have created an application in the IIS which points to the website project. The web site's bin folder has many assemblies which I need to refer. But those assemblies also have built using .NET 4 on the same computer.
I can browse the WCF service using both HTTP & HTTPS.
However, when i access the service from the test windows application (using the proxy class of the WCF contract), I get the error in question. Everything was working without problem earlier.
Anyone can help to fix the issue?. How to investigate this issue?
Error 0x80040154 means "Class Not Registered", which usually means you're depending on a COM component that hasn't been installed properly on the machine.
Is any of those Assemblies you reference a COM Interop Assembly? If so, find out what it uses and then install the appropriate COM component.

wcf service on mobile 5.0

I have writed a primitive wcf (vs 2010) service and created proxy files by svcutil. Later I created a mobile project on vs2008 and added proxy files on project but this error occured.
Error 1 The type or namespace name 'ServiceContractAttribute' does not exist in the namespace 'System.ServiceModel' (are you missing an assembly reference?) C:\Users\Abb\Documents\Visual Studio 2008\Projects\WCF\MobileService\MobileClient\Sample.cs
the proxy files runs well on console application (vs 2008) but there is errors on mobile.
System.ServiceModel doesnot support ServiceContractAttribute.
For mobile applications you shouldn’t use SvcUtil to generate proxies since this does not generate code compatible with the subset of WCF functionality available to the .NET Compact Framework on mobile devices.
Instead, you should use NetCFSvcUtil.exe. See this link for more information: Using NetCFSvcUtil.exe to interact with ServiceContracts

Ninject 2.0 incompatibility with Server 2008 R2?

I'm dev'ing an MVC 2 website targeting .NET 4.0 and using Ninject 2.0 (dev box running Win 7 64 pro). All is going well on the dev side, I really enjoyed using Ninject and it works a charm.
Until I deploy it to the server. Once I deploy the app to the server (a virtual machine running Win Server 2008 R2 x64, IIS 7.5) the ninject binding appear to simply not happen. I was first getting a null reference exception on the Logger that I was calling in OnApplicationStarted, I manually bound that and I got another null reference exception the very next time the code called for an injected component. Manually changing that one pushes the problem down the line.
I'm not getting any errors at all locally, and I'm not getting errors in the event log other than the null reference exceptions on injected components.
I have already verified that the server has .Net 4.0, MVC 2's dll, both Ninject DLLs and the DLLs of all my components. I was compiling against "any cpu" as well, in release mode.
Any ideas or known bugs w/ the platform I've described?
I'd post source code except that I figured it's not relevant since it's working locally unchanged.
Ninject works fine on Server 2008 R2. If you are experiencing a difference in functionality between your machine and the server, then something is different in your setup. There is no way to help you with the information you have provided so far. Please create a sample project that exhibits the issue and it will be a lot easier to help you.
-Ian

NHibernate, WCF & SqlServerCE - Exception thrown loading driver

Background
I have a BLL DLL that uses NHibernate. I share the same BLL between a client application and the WCF service (even though the client runs on another machine).
I can successfully use either SqlServerCe or SqlServer driver with the BLL with the client application but can only use the SqlServer driver for the WCF.
If I change the hibernate.cfg.xml to use SQL Server I am able to use the service as required with no exceptions being thrown.
The Error
The exact error from the log4net output is:
2421, 5, DEBUG, NHibernate.Connection.DriverConnectionProvider, (null),Obtaining IDbConnection from Driver
2483, 5, DEBUG, NHibernate.Connection.DriverConnectionProvider, (null),Exception thrown obtaining connection: Exception has been thrown by the target of an invocation.
I also have the following code in my WCF code behind file:
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
NOTES
WCF bin directory contains all required DLL's for NHibernate and SqlServerCe
Does not matter if System.Data.SqlServerCe.dll is in the GAC
Does not matter if System.Data.SqlServerCe.dll is added to the web.config file under assemblies
Operating Systems is Windows Server 2003 R2 SP2
.NET Framework 3.5SP1 installed
Visual Studio 2008 installed
Just incase, I uninstalled anything to do with compact edition but this still did not resolve the issue
The Question
How would you try and determine why NHibernate cannot load the SqlServerCe framework?
What forensic analysis would you perform to try and accurately determine the problem so that you can then find ways of resolving it?
Update 1
Incase it was my code I just created a simple website and am able to successfully use the ORM to insert and retrieve records using a hard-coded path to the SDF database. If I use the same hibernate configuration file for the webservice then exception is generated. This does narrow down the problem to the WCF implementation.
Well, clearing the ASP.NET temp cache did not do anything and deleting and republishing my site did nothing, but reverting to an VM Snapshot on the Windows 2003 R2 SP2 O/S did!
An update or myself must have done something to the OS that caused the problems.
I have a different problem now as the SQL is not successfully running under the environment but at least the NHibernate driver is loading and running to which this question was asking.
Update: Yes, I can only get NHibernate talking to SQL Server still and this is fine for the webservice endpoint. We will investigate the issues at a later stage. Marking this answer as the correct one as no other comments have been added.