Search code examples
asp.net-mvcapiiispublishing

Publishing my API project in another IIS


I've published my API project several times and it doesn't have any problem. but when I publish the same publish files in one of my server's IIS it rise a error about one of my controllers. I've checked it, it works properly in my local and another IIS.

This XML file does not appear to have any style information associated with it. The document tree is shown below. An error has occurred. An error occurred when trying to create a controller of type 'CityController'. Make sure that the controller has a parameterless public constructor. System.InvalidOperationException at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request) at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext() An error has occurred. Type 'Jabama.Web.API.Controllers.CityController' does not have a default constructor System.ArgumentException at System.Linq.Expressions.Expression.New(Type type) at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType) at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator) at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)

I checked all of the cityController's dependencies, there isn't any problem in it.


Solution

  • I finally found what's wrong. when I published the API project, it didn't publish the Microsoft.SqlServer.Type dll in it's bin folder.I copyed the dll manualy to that IIS and it's work but I don't know why it was giving me such an error! and even yet now what was wrong with my new IIS which the API didn't work without this dll, and the other IIS worked without this even without copying it!