azuric
azuric

Reputation: 2839

OWIN WebApp.Start gives A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

In my code i have this:

        HOST = "*";
        PORT = 9000;
        baseAddress = "http://" + HOST + ":" + PORT + "/";

        // Start OWIN host. Should be called in TT extension code
        WebApp.Start<Startup>(url: baseAddress);

which is leading to:

A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll Additional information: Exception has been thrown by the target of an invocation.

Online I have found a possible solution by typing in CMD run as Admin:

netsh http add urlacl url=http://+:9000/ user=Everyone

but this has not resolved the issue. Can anyone help?

Upvotes: 18

Views: 7148

Answers (2)

dave_k_smith
dave_k_smith

Reputation: 693

The urlacl suggestions above didn't help me. I was getting this exception when trying to use port 5000 (in later testing, port 9000 did not cause this exception for me). Changing to port 12345 (as suggested in the readme.txt after I ran Install-Package Microsoft.Owin.SelfHost -Pre in Package Manager Console) was my fix.

Upvotes: 0

Manuel Rauber
Manuel Rauber

Reputation: 1392

You simply run in an elevated cmd:

netsh http add urlacl url=http://*:9000/ user=your_user_name

Please note, that you mentioned using a star and not the plus sign. So you have to add a star route to your urlacl and not a plus route as mentioned in your post. After this, you don't have to start it as Admin.

Upvotes: 12

Related Questions