NLog GetCurrentClassLogger() NullReferenceException using StructureMap (Full Trust) - structuremap

It seems like NLog can't use reflection for GetCurrentClassLogger(), even though my MVC 3 app is deployed in a Full Trust environment on IIS7. I'm using StructureMap 2.6.1 and the problem seems to appear sporadically between deploys. I can't figure out why, though I don't think StructureMap is causing it.
Bootstrapper class:
public static class Bootstrapper
{
public static void ConfigureStructureMap()
{
ObjectFactory.Initialize(Init);
}
private static void Init(IInitializationExpression x)
{
x.AddRegistry(new DBServiceRegistry());
x.AddRegistry(new MyRegistry());
}
}
Registry class:
public class MyRegistry : Registry
{
public MyRegistry()//HttpContext context)
{
For<ILogger>().Use<NLogLogger>();
For<IUserRepository>().Use<SqlUserRepository>();
}
}
Everything works great on my machine. Why am I getting a System.NullReferenceException: Object reference not set to an instance of an object error when deploying?
[NullReferenceException: Object reference not set to an instance of an object.]
NLog.LogManager.GetCurrentClassLogger() +84
lambda_method(Closure , IArguments ) +40
StructureMap.Construction.<>c__DisplayClass2.<CreateBuilder>b__0(IArguments args) +22
StructureMap.Construction.InstanceBuilder.BuildInstance(IArguments args) +12
StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder) +88
[StructureMapException: StructureMap Exception Code: 207
Internal exception while creating Instance '38000383-149d-45c2-a8f3-7442316da725' of PluginType Todo.Data.ILogger. Check the inner exception for more details.]
StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder) +276
StructureMap.Pipeline.ConstructorInstance.build(Type pluginType, BuildSession session) +41
StructureMap.Pipeline.SmartInstance_1.build(Type pluginType, BuildSession session) +43
StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session) +45
StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session) +36
StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session) +103
StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance) +49
StructureMap.<>c__DisplayClass3.<.ctor>b__1() +22
StructureMap.BuildSession.CreateInstance(Type pluginType) +24
...etc...snipped

Turns out it's not a trust issue, but an IoC issue. Thanks to an NInject solution for steering me in the right direction.
Solution
For your logging wrapper, use a constructor that accepts a string parameter:
public class NLogLogger : ILogger
{
private Logger _logger;
public NLogLogger(string currentClassName)
{
_logger = LogManager.GetLogger(currentClassName);
}
...
}
NLog StructureMap Config:
For<ILogger>().Use<NLogLogger>()
.Ctor<string>("currentClassName")
.Is(x => x.BuildStack.Root.RequestedType.FullName);

Related

Cannot access admin page after EPiServer CMS 6 R2 to 7.5 upgrade

I have upgraded a site from EPiServer CMS 6 R2 to 7.5 via Deployment Center. After running the "Upgrade/disable Add-ons After Product Upgrade" I cannot access the back-end/admin page.
Error:
Exception details:
ActivationException: Activation error occurred while trying to get instance of type EPiDashboardController, key ""
Stack trace:
[ActivationException: Activation error occurred while trying to get instance of type EPiDashboardController, key ""]
at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at EPiServer.Shell.Web.Mvc.ModuleControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at EPiServer.Shell.Web.Mvc.ModuleMvcHandler.ProcessRequestInit(HttpContextBase httpContext)
at EPiServer.Shell.Web.Mvc.ModuleMvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
[Inner exception StructureMapException: StructureMap Exception Code: 207
Internal exception while creating Instance '0512faec-bb98-447c-a311-5bde00402363' of PluginType EPiServer.Shell.ViewComposition.IViewManager. Check the inner exception for more details.]
at StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder)
at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session)
at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session)
at StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session)
at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance)
at StructureMap.BuildSession.CreateInstance(Type pluginType)
at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session)
at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session)
at StructureMap.Pipeline.ConstructorInstance.Get[T](String propertyName, BuildSession session)
at lambda_method(Closure , IArguments )
at StructureMap.Construction.BuilderCompiler.FuncCompiler`1.<>c__DisplayClass2.b__0(IArguments args)
at StructureMap.Construction.InstanceBuilder.BuildInstance(IArguments args)
at StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder)
at StructureMap.Pipeline.SmartInstance`1.build(Type pluginType, BuildSession session)
at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session)
at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session)
at StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session)
at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance)
at StructureMap.BuildSession.CreateInstance(Type pluginType)
at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session)
at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session)
at StructureMap.Pipeline.ConstructorInstance.Get[T](String propertyName, BuildSession session)
at lambda_method(Closure , IArguments )
at StructureMap.Construction.BuilderCompiler.FuncCompiler`1.<>c__DisplayClass2.b__0(IArguments args)
at StructureMap.Construction.InstanceBuilder.BuildInstance(IArguments args)
at StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder)
at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session)
at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session)
at StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session)
at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance)
at StructureMap.BuildSession.CreateInstance(Type pluginType)
at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
Thanks in advance,
Problem is solved by giving folder permissions to IIS_IUSRS

Hangfire: The invoked member is not supported in a dynamic assembly

I'm trying to use Hangfire in my ASP MVC application, I have configured my application as follows:
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseHangfire(config =>
{
config.UseSqlServerStorage("myconnstring");
config.UseServer();
});
}
}
But I'm getting the following error every time I run my app:
[NotSupportedException: The invoked member is not supported in a dynamic assembly.]
System.Reflection.Emit.InternalAssemblyBuilder.get_Location() +56
log4net.Util.SystemInfo.AssemblyLocationInfo(Assembly myAssembly) +88
log4net.Core.DefaultRepositorySelector.GetInfoForAssembly(Assembly assembly, String& repositoryName, Type& repositoryType) +256
log4net.Core.DefaultRepositorySelector.CreateRepository(Assembly repositoryAssembly, Type repositoryType, String repositoryName, Boolean readAssemblyAttributes) +270
log4net.Core.DefaultRepositorySelector.CreateRepository(Assembly repositoryAssembly, Type repositoryType) +58
log4net.Core.DefaultRepositorySelector.GetRepository(Assembly repositoryAssembly) +115
log4net.Core.LoggerManager.GetLogger(Assembly repositoryAssembly, String name) +180
log4net.LogManager.GetLogger(Assembly repositoryAssembly, String name) +50
log4net.LogManager.GetLogger(String name) +55
lambda_method(Closure , String ) +39
Hangfire.Logging.LogProviders.Log4NetLogProvider.GetLogger(String name) +50
Hangfire.Logging.LogProvider.GetLogger(String name) +103
Hangfire.Logging.LogProvider.GetLogger(Type type) +53
Hangfire.SqlServer.SqlServerObjectsInstaller..cctor() +65

NullReferenceException in WebConfigScopeDictionary

Occasionally (about once a month) an ASP.NET MVC 3 web application fails with this exception.
System.NullReferenceException: Object reference not set to an instance of an object.
Server stack trace:
at System.Collections.Specialized.NameObjectCollectionBase.BaseGetAllKeys()
at System.Collections.Specialized.NameValueCollection.get_AllKeys()
at System.Web.WebPages.Scope.WebConfigScopeDictionary.<>c__DisplayClass4.<.ctor>b__0()
at System.Lazy`1.CreateValue()
Exception rethrown at [0]:
at System.Lazy`1.get_Value()
at System.Web.WebPages.Scope.WebConfigScopeDictionary.TryGetValue(Object key, Object& value)
at System.Web.Mvc.ViewContext.ScopeGet[TValue](IDictionary`2 scope, String name, TValue defaultValue)
at System.Web.Mvc.ViewContext.ScopeCache..ctor(IDictionary`2 scope)
at System.Web.Mvc.ViewContext.ScopeCache.Get(IDictionary`2 scope, HttpContextBase httpContext)
at System.Web.Mvc.ViewContext.GetClientValidationEnabled(IDictionary`2 scope, HttpContextBase httpContext)
at System.Web.Mvc.Html.FormExtensions.FormHelper(HtmlHelper htmlHelper, String formAction, FormMethod method, IDictionary`2 htmlAttributes)
at ASP._Page_Views_mywebpage_Create_cshtml.Execute() in c:\App\Views\Mywebpage\Create.cshtml:line 11
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.StartPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
This exception occurs on a line with
#using (Html.BeginForm())
From the moment this exception occurs once, the application is unusable. Every view will start throwing this error. I've looked around in the source code but seem unable to find anything. There are people who experience the same behaviour but with a different error and or by different code.
When digging deeper in the source of WebConfigScopeDictionary you can see that the AppSettings are being read:
public WebConfigScopeDictionary() : this(WebConfigurationManager.AppSettings)
{
}
public WebConfigScopeDictionary(NameValueCollection appSettings)
{
this._items = new Lazy<Dictionary<object, object>>(() => appSettings.AllKeys.ToDictionary((string key) => key, (string key) => appSettings[key], ScopeStorageComparer.Instance));
}
The appsettings come from the ConfigurationManager:
public static NameValueCollection AppSettings
{
get
{
object section = ConfigurationManager.GetSection("appSettings");
if (section == null || !(section is NameValueCollection))
{
throw new ConfigurationErrorsException(SR.GetString("Config_appsettings_declaration_invalid"));
}
return (NameValueCollection)section;
}
}
If there would be a problem with the web.config this code should have thrown an exception. But it doesn't. Eventually count is called on the collection that is returned by the AppSettings property. Since it is probably null at this point it throws.
protected string[] BaseGetAllKeys()
{
int count = this._entriesArray.Count;
string[] array = new string[count];
for (int i = 0; i < count; i++)
{
array[i] = this.BaseGetKey(i);
}
return array;
}
If anyone has any ideas, feel free to share.
After enquiring with the ops team it would appear that the application pool was being recycled after the timed interval had expired. This happened during office hours while the application is under a significant load. We've now changed it to recycle at a specific time, which is still a workaround but should prevent the problem from occurring too frequently.

Structuremap does not work on MVC4

I've used StructureMap in MVC2/3 many times without any concern, but I guess handling IoC is different in MVC4.
When i used StructureMap for handling IoC in MVC4 I get the following exception.:
No parameterless constructor defined for this object
Why?
I have not found any correct result in google except this: IoC Not Working In MVC4
These is my IoC classes:
public static class IoC {
public static IContainer Initialize() {
ObjectFactory.Initialize(x =>
{
x.Scan(scan =>
{
//scan.Assembly("DLL.Core");
scan.Assembly("DLL.CMS");
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
x.For<IDbContext>().Use<ModelEntities>();
x.For(typeof(IRepository<>)).Use(typeof(Repository<>));
x.For<IHttpControllerActivator>();
x.For<IController>();
});
return ObjectFactory.Container;
}
And SmDependencyResolver is:
public class SmDependencyResolver : IDependencyResolver
{
private readonly IContainer _container;
public SmDependencyResolver(IContainer container)
{
_container = container;
}
public object GetService(Type serviceType)
{
if (serviceType == null) return null;
try
{
return serviceType.IsAbstract || serviceType.IsInterface
? _container.TryGetInstance(serviceType)
: _container.GetInstance(serviceType);
}
catch
{
return null;
}
}
public IEnumerable<object> GetServices(Type serviceType)
{
return _container.GetAllInstances(serviceType).Cast<object>();
}
}
And my error is:
No parameterless constructor defined for this 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.MissingMethodException: No parameterless constructor defined for this 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:
[MissingMethodException: No parameterless constructor defined for this
object.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type,
Boolean publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
skipCheckThis, Boolean fillCache) +98
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean
fillCache) +241 System.Activator.CreateInstance(Type type, Boolean
nonPublic) +69
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext
requestContext, Type controllerType) +67
[InvalidOperationException: An error occurred when trying to create a
controller of type
'Parsian.Web.Areas.Dashboard.Controllers.MemberController'. Make sure
that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext
requestContext, Type controllerType) +182
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext
requestContext, Type controllerType) +80
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext
requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase
httpContext, IController& controller, IControllerFactory& factory)
+196 System.Web.Mvc.<>c__DisplayClass6.b__2() +49 System.Web.Mvc.<>c__DisplayClassb1.<ProcessInApplicationTrust>b__a()
+13 System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action
action) +22
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func1 func)
+124 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +98
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext,
AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext
context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+8862676 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Thanks for correct answers.
oops.I found an emergency solution :) Try to implement a class from IControllerActivator
public class StructureMapControllerActivator : IControllerActivator
{
private IContainer _container;
public StructureMapControllerActivator(IContainer container)
{
_container = container;
}
public IController Create(RequestContext requestContext, Type controllerType)
{
return _container.GetInstance(controllerType) as IController;
}
}
and then register it to the IoC class:
x.For<IControllerActivator>().Use<StructureMapControllerActivator>();
and then enjoy it.
Good luck
If you remove any old configuration for structuremap and install structurmap.mvc4 from nuget then configure your IoC container, you don't have any problems.
try adding this class as your ControllerFactory, I've actually seen the error above in MVC3 and this usually fixed it for me
public class StructureMapControllerFactory : DefaultControllerFactory
{
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
try
{
return (controllerType == null)
? base.GetControllerInstance(requestContext, controllerType)
: ObjectFactory.GetInstance(controllerType) as IController;
}
catch (Exception ex)
{
return null;
}
}
}
Using StructureMap.MVC5.Update I had to do this or else the nested IContainer was already disposed (weird) :
public class StructureMapControllerActivator : IControllerActivator
{
public IController Create(RequestContext requestContext, Type controllerType)
{
return StructuremapMvc.StructureMapDependencyScope.GetInstance(controllerType) as IController;
}
}

My code is being compiled to absolute paths!

I'm having problems deploying my application to a production server (shared hosting). Everything works fine on my development machine but not on the server due to absolute paths, here's a stack trace:
[SqlException (0x80131904): Login failed for user 'GLASGOW\IWPD_1479(fisharw)'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5009598
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +183
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection.Open() +125
System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection sqlConnection, Action`1 act) +85
System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection sqlConnection, Action`1 act) +349
System.Data.SqlClient.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +265
System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +34
[ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.]
System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +163
System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +40
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +157
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +51
System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +117
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +407
System.Data.Entity.Internal.LazyInternalContext.get_ObjectContext() +15
System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext() +20
Sharwe.Data.DataAccess.SharweEntities..ctor() in C:\Users\Kassem\Desktop\Sharwe\Sharwe.Data\DataAccess\SharweEntities.cs:14
Sharwe.Data.DataAccess.EfDatabaseFactory.GetDbContext() in C:\Users\Kassem\Desktop\Sharwe\Sharwe.Data\DataAccess\EFDatabaseFactory.cs:14
Sharwe.Data.DataAccess.GenericMethodsRepository..ctor(IDatabaseFactory dbFactory) in C:\Users\Kassem\Desktop\Sharwe\Sharwe.Data\DataAccess\GenericMethodsRepository.cs:21
lambda_method(Closure , IArguments ) +80
StructureMap.Construction.<>c__DisplayClass2.<CreateBuilder>b__0(IArguments args) +22
StructureMap.Construction.InstanceBuilder.BuildInstance(IArguments args) +12
StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder) +88
[StructureMapException: StructureMap Exception Code: 207
Internal exception while creating Instance 'ac34765c-b076-4f77-be6e-eb4739ea2738' of PluginType Sharwe.Data.Abstract.IGenericMethodsRepository. Check the inner exception for more details.]
StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder) +276
StructureMap.Pipeline.ConstructorInstance.build(Type pluginType, BuildSession session) +41
StructureMap.Pipeline.SmartInstance`1.build(Type pluginType, BuildSession session) +43
StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session) +45
StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session) +36
StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session) +103
StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance) +49
StructureMap.<>c__DisplayClass3.<.ctor>b__1() +22
StructureMap.BuildSession.CreateInstance(Type pluginType) +24
StructureMap.Pipeline.DefaultInstance.build(Type pluginType, BuildSession session) +76
StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session) +45
StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session) +36
StructureMap.Pipeline.ConstructorInstance.Get(String propertyName, BuildSession session) +73
StructureMap.Pipeline.Arguments.Get(String propertyName) +64
lambda_method(Closure , IArguments ) +35
StructureMap.Construction.<>c__DisplayClass2.<CreateBuilder>b__0(IArguments args) +22
StructureMap.Construction.InstanceBuilder.BuildInstance(IArguments args) +12
StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder) +98
StructureMap.Pipeline.ConstructorInstance.build(Type pluginType, BuildSession session) +41
StructureMap.Pipeline.SmartInstance`1.build(Type pluginType, BuildSession session) +43
StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session) +45
StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session) +36
StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session) +103
StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance) +49
StructureMap.<>c__DisplayClass3.<.ctor>b__1() +22
StructureMap.BuildSession.CreateInstance(Type pluginType) +24
StructureMap.Pipeline.DefaultInstance.build(Type pluginType, BuildSession session) +76
StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session) +45
StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session) +36
StructureMap.Pipeline.ConstructorInstance.Get(String propertyName, BuildSession session) +73
StructureMap.Pipeline.Arguments.Get(String propertyName) +64
lambda_method(Closure , IArguments ) +35
StructureMap.Construction.<>c__DisplayClass2.<CreateBuilder>b__0(IArguments args) +22
StructureMap.Construction.InstanceBuilder.BuildInstance(IArguments args) +12
StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder) +98
StructureMap.Pipeline.ConstructorInstance.build(Type pluginType, BuildSession session) +41
StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session) +45
StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session) +36
StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session) +103
StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance) +49
StructureMap.<>c__DisplayClass3.<.ctor>b__1() +22
StructureMap.BuildSession.CreateInstance(Type pluginType) +24
StructureMap.Container.GetInstance(Type pluginType) +67
Sharwe.MVC.Services.StructureMapDependencyResolver.GetService(Type serviceType) in C:\Users\Kassem\Desktop\Sharwe\Sharwe\Services\StructureMapDependencyResolver.cs:24
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +51
[InvalidOperationException: An error occurred when trying to create a controller of type 'Sharwe.MVC.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +182
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +196
System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +49
System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +13
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +124
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +98
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841400
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
So as you can see, there are several places where it says C:\Users\Kassem\Desktop\Sharwe\Sharwe\ which is where the project is located on my local machine. I do not understand why the code compiled this way, shouldn't it use relative paths automatically?
Note: My solution is divided into 3 projects, one of them is an ASP.NET MVC3 application which references the other projects (code libraries). In order to compile the whole project I right clicked on the MVC3 project and chose Build, and from there I deployed to a local directory then uploaded the files to the server.
Any suggestions?
This is just debug information embedded in the pdb file.... That's all. It's used when debugging to find the original source code.

Resources