我的代码被编译为绝对路径!
我在将应用程序部署到生产服务器(共享托管)时遇到问题。在我的开发计算机上一切正常,但由于绝对路径,在服务器上一切正常,这是堆栈跟踪:
[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
正如您所看到的,有几个地方显示 C:\Users\Kassem\Desktop\Sharwe\Sharwe \
这是项目在我的本地计算机上的位置。我不明白为什么代码会这样编译,它不应该自动使用相对路径吗?
注意:我的解决方案分为3个项目,其中一个是引用其他项目(代码库)的ASP.NET MVC3应用程序。为了编译整个项目,我右键单击 MVC3 项目并选择“构建”,然后从那里部署到本地目录,然后将文件上传到服务器。
有什么建议吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是嵌入在 pdb 文件中的调试信息......仅此而已。调试时使用它来查找原始源代码。
This is just debug information embedded in the pdb file.... That's all. It's used when debugging to find the original source code.