38
votes

I have an ASP.NET application that runs fine on my local machine. I just uploaded it to a server using web deploy. I'm getting the following error when I try to view the site:

The following errors occurred while attempting to load the app. - The OwinStartup attribute discovered in assembly 'Gators3' referencing startup type 'Gators3.Startup' conflicts with the attribute in assembly 'MyFirstProject2' referencing startup type 'MyFirstProject2.Startup' because they have the same FriendlyName ''. Remove or rename one of the attributes, or reference the desired type directly. To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config. To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.

I tried searching the entire solution for the string "MyFirstProject2" but did not come up with anything. The message gives a couple of suggestions, but none of them mean anything to me. I don't know how to "Remove or rename one of the attributes, or reference the desired type directly," and I don't see a place in the web.config to "add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config."

I found this, but am not quite sure how to implement it. I also did find [assembly: OwinStartupAttribute(typeof(Gators3.Startup))] in my Startup.cs, but not sure what the right thing to do there is either.

12
I had the same problem, just on a single dev box, after I renamed the project. Nishamth's answer worked for me.PeteH

12 Answers

68
votes

The problem is that the Gators3.dll and MyFirstProject2.dll are in the same folder (I guess it is bin folder on your server) and both are using Owin middleware. If you do not need MyFirstProject2.dll then the easiest way would be to delete that assembly. If you need it, but without Owin - add following line to Web.config/app.config in your MyFirstProject2 project: <add key="owin:AutomaticAppStartup" value="False" />

If you need to use Owin for two projects configure friendly names for both of them.

  • Gators3 project:

Change Owin startup attribute to something like:

 attribute [assembly: OwinStartupAttribute("GatorsConfig", typeof(Gators3.Startup))]

And add following line to Web.config within appSettings section:

   <add key="owin:appStartup" value="GatorsConfig" /> 
  • MyFirstProject2 project:

Change Owin startup attribute to something like:

   attribute [assembly: OwinStartupAttribute("MyFirstProject2Config", typeof(MyFirstProject2.Startup))]

And add following line to Web.config within appSettings section:

   <add key="owin:appStartup" value="MyFirstProject2Config" />
26
votes

I had the same issue : removing everything in the bin folder and rebuilding the solution alone worked for me. But it could be combined with renaming your assembly attribute at the top of the startupclass, giving it a Firendly name which will help to differentiate both the startup files.

[assembly: OwinStartup("MyFriendlyNameForProject1",typeof(MyProject.Startup))]
22
votes

Clear your bin folder and obj folder.Rebuild the project again and run :)

6
votes

Delete anything that says 'MyFirstProject2' from your bin folder and rebuild the solution, It will work.

6
votes

Also, if you publish a solution to Azure:

1) right click and select Publish.
2) go to Settings and expand the "File Publish Options"
3) select "Remove additional files at destination"
4) Publish

Worked for me, after deleting the files from obj and bin Folder.

4
votes

Happens when you reference (by mistake?) a project with owin startup inside another project with owin startup. Fix - delete the reference, bin, obj folders and rebuild.

3
votes

I had the same problem and i added the following tag on web config:

<appSettings>
    <add key="owin:AutomaticAppStartup" value="false" />
</appSettings>
2
votes

This is what I have done:

  1. Since I have 3 projects in one solution, I had to open all bin folder of each project and delete all files there.

  2. Build each project one by one.

  3. Build the whole solution.

Problem solves on my part.

2
votes

Remove all files in your 'bin' folder and rebuild.

1
votes

Delete files Bin, Build each project one by one.

1
votes

Deleted everything in the bin folder, including the roslyn folder then published, and everything worked fine.

0
votes

Remove old built data in temporary files, in the following path

C:\Users\[user]\AppData\Local\Temp\Temporary ASP.NET Files\vs