ASP.NET Web Application types not found

Introduction 
When I was converting a Web site to a ASP.NET Web Application project in Visual Studio 2008, all my classes in the App_Code folder were not recognized any longer.

After some small investigation, it seemed that App_Code cannot be used in an ASP.NET Web Application project in Visual Studio (2005/2008). So, I put all the classes, before located in App_Code, to subfolders of the project and added the corresponding namespaces.

Problem
However, I was still getting the following compile error:

Error 129 The type or namespace name 'MyClass' could not be found (are you missing a using directive or an assembly reference?)

After googling for this problem, I still couldn't find the problem. Then I thought: wait, are the classes even being compiled? No, the classes were actually not compiled. Somehow, the classes were set as content.

Fix
Select the file that is not being compiled in the solution explorer and view its properties (hit F4). Make sure the Build Action is set to Compile, and not to Content (which was the case with my project).

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Updater and Nullsoft installer

Thomas Younsi wrote a great article on how to combine Updater with Nullsoft installer.

 You can read it at his blog.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

WSE306: FramingFormatException

For one of my clients, I needed to develop a web service inside a windows service. Developing the windows service is fairly simple since I used WSE. I developed the web service so it used a soap.tcp procotol. When using a C# client, everything worked fine.

However, the client already developed a server component (let's call it broker) in C++ and gSOAP. When connecting to the web service via gSOAP (or any other 3rd party non-WSE method). One of the problems I walked into was:

WSE306: The DIME record should have the following version: 1. Instead, the DIME record contained the following version:

There are more people that are having this error, but no one seems to know the solution. So, I decided to convert the protocol to http by using the HTTP.SYS transport developed by Aaron Skonnard. This way, I was able to get more information on the error that occurred since I was able to see the exact data that was sent to the web service.

Now, I noticed that WSE was unable to send the message directly to the service, and therefore generated the exception mentioned above. The exact problem were the addressing headers. WSE requires WS-Addressing headers to be sent, but "normal" soap-messages do not contain these headers.

For gSOAP, the solution is fairly simple: read this article on how to enable WS-Addressing in gSOAP.

Now, I was able to add the required WS-Addressing headers. Finally, I was able to fix the strange (and until now unsolved) exception WSE306: FramingFormatException. It is simply because the WS-Addressing headers are missing!

The only thing for me to do now is to convert the protocol back to soap.tcp instead of http. However, the first results are bad: it seems that other tools are unable to communicatie using soap.tcp.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Web Services inside Windows Services

Some time ago, a client required me to develop a Web Service and Windows Service combined. I started searching on the internet for possibilities and stumbled across this great tutorial.

I started a new Windows Service and followed all the steps in the tutorial. All compiled well and I started my Windows Service (and with that, the Web Service). However, as soon as I tried to connect to the Web Service, I received an error message "Server actively refused connection".

Let me tell a little background story about the requirements for the product. The Windows Service would run on the machine that has the IP that has a DNS entry [ServiceName].[Company].com. I wanted to start the Web Service on localhost (since I was already on the right computer).

When you try to connect to soap.tcp://localhost:[port]/[ServiceName], it will succeed. However, as soon as you try to connect to soap.tcp://[ServiceName].[Company].com/MyService, you will receive the actively refused error. When you run netstat -a, it will show you that the Web Service is listening at the right port, but why isn't it working?

The solution is that you cannot directly connect to soap.tcp://[ServiceName].[Company].com/MyService. You should first resolve the DNS entry and then connect to that result using the following code:

[code:c#]
/// <summary>
/// Initializes the soap service listener
/// </summary>
private void InitializeServiceListener()
{
    try
    {
        // Create address
        string address = string.Format("soap.tcp://{0}:{1}/{2}",
        Dns.GetHostAddresses(Dns.GetHostName())[0],
        Settings.Default.ServicePort, Settings.Default.ServiceName);

        // Create SOAP listener & endpoint
        Uri addressUri = new Uri(address);

        // Start hosting the web service
        SoapReceivers.Add(new EndpointReference(addressUri), typeof(CommandListener));

        // Log
        EventLogHelper.EventLog.WriteEntry(address, EventLogEntryType.Information);
    }
    catch (Exception ex)
    {
        // Log
        EventLogHelper.EventLog.WriteEntry(string.Format(Resources.ErrorInitializingWebservice, ex.Message),
        EventLogEntryType.Error);
    }
}
[/code]

As you see, you should get the hostname of the current computer to start the service. The address will be exactly the same as when you type it, but now it will work.

For the client side, you should do the same:

[code:c#]
// Set up server
MyService server = new MyService ();
server.Url = string.Format("soap.tcp://{0}:{1}/[ServiceName]",
Dns.GetHostEntry("[ServiceName].[Company].com").AddressList[0], Settings.Default.ServicePort);
[/code]

Now the Web Service inside the Windows Service will work as planned.

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Welcome to my blog

Welcome to my first blog entry on this blog.

I start this blog since I sometimes walk into problems where the solution is hard to find. Most people (in this case, developers) use Google (or another searchengine) to find a solution to the problems they walk into.

However, sometimes even Google can't help you out and you have to find out the information yourself. For the problems I solve myself (sometimes with the help of others), this will be a new place where I will blog all problems, and even more important, the solution to these problems.

I hope you will enjoy my blog!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5