42

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.

abalter
  • 9,663
  • 17
  • 90
  • 145
  • Possible Duplicate : http://stackoverflow.com/questions/21701297/error-when-renaming-asp-net-mvc-5-application – Farhan S. Oct 03 '15 at 10:23
  • I had the same problem, just on a single dev box, after I renamed the project. Nishamth's answer worked for me. – PeteH Jun 26 '19 at 18:17

13 Answers13

72

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" />
LaoR
  • 1,278
  • 1
  • 10
  • 19
28

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))]
Nishanth Shaan
  • 1,422
  • 15
  • 18
  • 7
    Manually ensuring `/bin` folder is cleaned (=delete all files), was the key to me (thx). Renaming assembly, "cleaning" from within VS and rebuilding is not enough, since the clean will not be able to know about the legacy dll's, since these still have the same old name – Frederik Struck-Schøning Apr 15 '16 at 12:25
  • Manually ensuring /bin folder is cleaned is fully solution – Sultan Dec 25 '20 at 20:15
25

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

7

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.

Michael Staples
  • 537
  • 7
  • 13
6

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

  • well this works for me. no more additional configurations needed. I just clear up the bin folder. and then rebuild and it works like magic.. – Tsuna Sawada Jul 11 '19 at 14:19
4

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.

Nick Kovalsky
  • 5,378
  • 2
  • 23
  • 50
3

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

<appSettings>
    <add key="owin:AutomaticAppStartup" value="false" />
</appSettings>
  • 1
    This worked for me! I also deleted before the bin and obj folders of all projects in the solution, and updated the package with the code: "Update-Package Microsoft.AspNet.WebApi -reinstall" – Sterling Diaz Jul 11 '18 at 15:13
  • 1
    If **false** - public static void InitialiseThis(**HttpApplication** application) is called, when **true** public static void Configuration(**IAppBuilder** app/*, IServiceCollection services*/) – Jan Sep 05 '20 at 09:44
2

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.

Willy David Jr
  • 8,604
  • 6
  • 46
  • 57
2

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

Sudheer Muhammed
  • 813
  • 8
  • 10
1

Delete files Bin, Build each project one by one.

1

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

George Williams
  • 147
  • 1
  • 10
0

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

C:\Users\[user]\AppData\Local\Temp\Temporary ASP.NET Files\vs
Andrei Dragotoniu
  • 6,155
  • 3
  • 18
  • 32
mosi98
  • 575
  • 6
  • 16
0

In my case, I was referencing one project in the other accidentally, which is why I was getting this error after removing the one accidentally added in the main project solved the problem.

Munam Yousuf
  • 431
  • 1
  • 6
  • 17