views:

988

answers:

3

I wrote a simple web service in C# using SharpDevelop (which I just got and I love).

The client wanted it in VB, and fortunately there's a Convert To VB.NET feature. It's great. Translated all the code, and it builds. (I've been a "Notepad" guy for a long time, so I may seem a little old-fashioned.)

But I get this error when I try to load the service now.

Parser Error Message: Could not load type 'flightinfo.Soap' from assembly 'flightinfo'.

Source Error:

Line 1:  <%@ WebService Class="flightinfo.Soap,flightinfo" %>

I have deleted the bins and rebuilt, and I have searched google (and stackoverflow). I have scoured the project files for any remnants of C#.

Any ideas?

A: 
<%@ WebService Class="flightinfo.Soap,flightinfo" %>

What is the name of your class?

FlySwat
flightInfo.Soap -- same as before. This was actually generated by the web service template.
harpo
And the assembly is still flightInfo?
FlySwat
yep. Pretty wierd, huh?
harpo
A: 

The problem may be cause by VB.NET & C# projects using different naming conventions for project assemblies and how the project namespace is used. At least that's were I would start looking.

Sixto Saez
+1  A: 

In VB.NET, namespace declarations are relative to the default namespace of the project. So if the default namespace for the project is set to X.Y, everithyng between Namespace Z and End Namespace will be in the X.Y.Z namespace. In C# you have to provide the full namespace name, regardless of the default namespace of the project. So if the C# project had the default namespace X.Y, the CS files would still include the namespace X.Y declaration. After converting to VB, if both the default namespace and the namespace declarations in the files stay the same you end up with classes in the X.Y.X.Y namespace. So in your case, the Soap class is now in the flightinfo.flightinfo namespace. Thus there are three possible solutions:

  • change the asmx file to

    <%@ WebService Class="flightinfo.flightinfo.Soap,flightinfo" %>

  • remove the default namespace from the project

  • remove the namespace declarations from the vb files
csgero
You're right! I had worked around this by sending the source files to the client (who created his own project and had no problem). But I noticed your answer, and tried it out. I had to prefix the class name with the project name, which as you say is the default (implicit) namespace. Thanks!
harpo