Search
Resolved
as Fixed Help for as Fixed

1
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 495882
Opened: 10/5/2009 6:16:11 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Sometimes i get this Exeception:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
System.UriTemplateCompoundPathSegment.IsEquivalentTo(UriTemplatePathSegment other, Boolean ignoreTrailingSlash) +68
System.UriTemplate.IsPathFullyEquivalent(UriTemplate other) +211
System.UriTemplate.IsEquivalentTo(UriTemplate other) +41
System.ServiceModel.Dispatcher.WCFKey.Equals(Object obj) +41
System.Collections.Generic.ObjectEqualityComparer`1.Equals(T x, T y) +37
System.Collections.Generic.Dictionary`2.FindEntry(TKey key) +251
System.ServiceModel.Dispatcher.WebHttpDispatchOperationSelector..ctor(ServiceEndpoint endpoint) +367
System.ServiceModel.Description.WebHttpBehavior.GetOperationSelector(ServiceEndpoint endpoint) +24
System.ServiceModel.Description.WebHttpBehavior.ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) +185
Microsoft.ServiceModel.Web.WebHttpBehavior2.ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) in d:\dd\SP_1\src\ndp\cdf\src\hilo\stagingCodeplex-R2\Microsoft.ServiceModel.Web\Microsoft.ServiceModel.Web\WebHttpBehavior2.cs:46
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +3858
System.ServiceModel.ServiceHostBase.InitializeRuntime() +37
System.ServiceModel.ServiceHostBase.OnBeginOpen() +27
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +49
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +121
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479

[ServiceActivationException: The service 'XXX' cannot be activated due to an exception during compilation. The exception message is: Object reference not set to an instance of an object..]
System.ServiceModel.AsyncResult.End(IAsyncResult result) +11592858
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context) +23
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
Details (expand)

Product Version

.NET Framework 3.5 SP1
Product Language
English

Operating System
Windows 7 (client)
Operating System Language
Other ( please specify in Repro Steps)

Architecture
x86

Priority
(1=blocking, 2=important, 3=nice to have)
2

Severity
(1=major functionality issue, 2=important functionality issue, 3=nice to have)
2

Steps to Reproduce
I use the "Microsoft.ServiceModel.Web.WebServiceHost2Factory" to build the WCF Service Configuration.
In Visual Studio click on Run with Default Debug Configuration. When a Method is invoked on the WCF Service then the Exception (see Description) is thrown.
Now i change from Debug configuration to Release configuration and build again. The Service works without any Exception.
Again change to Debug and also the Debug configuration works, extraordinary.
Then a awhile ago the same Exception is thrown.
Actual Results
see Steps to Reproduce...
Expected Results
see Steps to Reproduce...
Component Usage
(any information on your scenario that may help in investigating your issue)
Operation System: Windows 7 and Windows Vista both Enterpreis Edition
Operation System Language: German
Used component; WCF REST Starter Kit Preview 2

How often does this happen?
Sometimes Happens

Have you seen this problem in other versions?
I don't know if this issue existed previously
File Attachments
0 attachments
Sign in to post a comment.
Posted by jacobsrl on 10/5/2009 at 8:55 AM
It is difficult to say what might be causing this without more info or a project that can reproduce it. Can you give us more detail?
Posted by dead3y3 on 10/6/2009 at 2:11 AM
Hi, my colleague has found the issue. We have a partial Interface as contract. In this Interface we have the following method signature:
[OperationContract]
[WebGet(UriTemplate = "MessageFeed/{id}.Json")]
Stream GetMessageFeedJson(string id);

When this is comment out than the exception is gone. No idea what happened.
Posted by Microsoft on 10/6/2009 at 8:32 PM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com/)
Posted by Microsoft on 10/9/2009 at 2:52 PM
Could you send the contract that you are using? We are particularly interested in the UriTemplates.
Posted by Microsoft on 10/9/2009 at 4:14 PM
Hi dead3y3,

Thanks for submitting this bug! This appears to be a bug in the REST Starter Kit code when it compares UriTemplate objects. The issue has been fixed and it will be part of a future release. As a workaround, reordering the methods in your contract should work. As a specific example, if you have a contract like the following:

    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebGet]
        string SayHello(string name);

        [OperationContract]
        [WebGet(UriTemplate = "MessageFeed/{name}.Json")]
        string SayHello2(string name);

        [OperationContract]
        [WebGet(UriTemplate = "MessageFeed/{name}")]
        string SayHello3(string name);

    }

This will produce the exception like you're seeing. If you reorder the methods with UriTemplates above, it will work:

    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebGet]
        string SayHello(string name);

        [OperationContract]
        [WebGet(UriTemplate = "MessageFeed/{name}")]
        string SayHello3(string name);

        [OperationContract]
        [WebGet(UriTemplate = "MessageFeed/{name}.Json")]
        string SayHello2(string name);

    }


If this does not help your scenario, feel free to reopen the bug and include the contract(s) you are using. You may also contact me directly at dmetzgar@microsoft.com.

Thank you,
Dustin Metzgar
Posted by dead3y3 on 10/12/2009 at 2:44 AM
Hi Dustin,

i tested your advice and it works !

Thanks for help
Posted by jdf22 on 10/15/2009 at 7:45 AM
Hello, W

We're suffering from the same issue from a service codebase that will run fine on a Vista Ultimate x64 machine, but will throw the NullReferenceException from System.UriTemplateCompoundPathSegment.IsEquivalentTo on an XP Professional SP3 machine. Both machines are running the latest .NET framework 3.5 SP1. I don't know if the OS in this case helps make the difference, I suspect not :-)

The code actually had to be reordered in the way you suggested above in order to get it working on the Vista machine. We thought we had the problem solved only to discover that the re-ordered code doesn't work around the problem on the XP machine. This makes relying on the code after it's been shipped a problem, since the usefulness of the workaround appears to be dependent on which machine the code is run on.

Please let us know what to do!

Best wishes,
jdf22

Is there a solution we can work on that will guarantee to run on any machine?