I wrote a very simple WCF data service. But I find that can't work when I deploy on IIS7.5. It just only can work on IIS Express.
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class WcfDataService : DataService<ConfigurationDataEntities>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
config.UseVerboseErrors = true;
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
// config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
}
}
This is webconfig file
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework5" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="ConfigurationDataEntities" connectionString="metadata=res://*/ConfigurationDataModel.csdl|res://*/ConfigurationDataModel.ssdl|res://*/ConfigurationDataModel.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="data source=|DataDirectory|\ConfigurationData.sdf;password=123;persist security info=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
</system.web>
<entityFramework5>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework5>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>
This is the error message:
The server encountered an error processing the request. See server logs for more details.
在 System.Data.Entity.DbContext..ctor(String nameOrConnectionString) 在 WcfDataServiceTest.ConfigurationDataEntities..ctor() 位置 c:\Projects\WcfDataServiceTest\WcfDataServiceTest\ConfigurationDataModel.Context.cs:行号 18 在 invoke_constructor() 在 System.Data.Services.DataService1.CreateDataSourceInstance() 在 System.Data.Services.DataService1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider& metadataProviderInstance, IDataServiceQueryProvider& queryProviderInstance, BaseServiceProvider& builtInProvider, Object& dataSourceInstance) 在 System.Data.Services.DataService1.CreateProvider() 在 System.Data.Services.DataService1.HandleRequest() 在 System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody) 在 SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] ) 在 System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) 在 System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) 在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) 在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) 在 System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
Anyone can help me?
WCF helps you:
See server logs for more details.
Configure tracing and see where the exception occurs. Since it's happening in the DbContext constructor, I assume there's something with database access. Check the account the application pool runs under and verify this account can access the database.
Related
I made a WCF Rest Service and attached it to IIS 7 on my server and it worked great. Suddenly, we had a hard drive failure and the guys who're supposed to manage the backups didn't back up anything, so we lost all our stuff on the server.
So I go about setting everything back up, and I put all the stuff on IIS. We have another WCF Rest Service that does a lot of stuff the one I made does, including a couple of the same methods for authentication and such. But now it seems that mine won't work. Our website works and our other web service works, but not this one, and I've no idea why? I set them up the exact same and I don't think I changed anything when I did it initially.
The help reference pages work, but when calling the method, I get
"The server encountered an error processing the request. Please see the service help page for constructing valid requests to the service."
I'm using the same methods as before, calling them with the same arguments, this happens for every method, regardless of GET or POST. I've used a REST extension thing in chrome to call it and the mobile app that I usually use to call it, as well as the browser and they all come up with the same error.
Here's the web.config file for it (I've tried adding a few things found on stackoverflow to get to the problem, but it's not done anything, really).
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
</system.webServer>
<system.serviceModel >
<behaviors>
<serviceBehaviors>
<behavior name="DataServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings >
<!-- pick whichever binding you want .... -->
<basicHttpBinding>
<!-- binding configuration with a name -->
<binding name="ExtendedMaxSize"
maxBufferSize="52428800" maxReceivedMessageSize="52428800" >
<readerQuotas maxDepth="52428800" maxStringContentLength="52428800"
maxArrayLength="52428800" maxBytesPerRead="52428800" maxNameTableCharCount="52428800" />
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" defaultOutgoingResponseFormat="Json" crossDomainScriptAccessEnabled="true" maxReceivedMessageSize="52428800" maxBufferSize="52428800" maxBufferPoolSize="52428800" />
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
</configuration>
After turning tracing on, got this error from the viewer:
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System
xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131076</EventID><Type>3</Type><SubType Name="Error">0</SubType><Level>2</Level><TimeCreated SystemTime="2014-03-27T12:15:47.5749853Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{54672f7e-5a71-4dda-92a3-f07f7c94ccb9}" /><Execution ProcessName="w3wp" ProcessID="20820" ThreadID="9" /><Channel /><Computer>OHS-VMHOST-NEW</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord Severity="Error" Channel="Operational" xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"><TraceIdentifier>http://msdn.microsoft.com/en-GB/library/System.ServiceModel.Diagnostics.TraceHandledException.aspx</TraceIdentifier><Description>Handling an exception. Exception details: System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at OHS.MobileAssessor.Services.MobileAssessorAPIService.GetProjectData(String token)
at SyncInvokeGetProjectData(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</Description><AppDomain>/LM/W3SVC/1/ROOT/mobileassessor-1-130403961472161807</AppDomain><Exception><ExceptionType>System.FormatException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).</Message><StackTrace> at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at OHS.MobileAssessor.Services.MobileAssessorAPIService.GetProjectData(String token)
at SyncInvokeGetProjectData(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><ExceptionString>System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at OHS.MobileAssessor.Services.MobileAssessorAPIService.GetProjectData(String token)
at SyncInvokeGetProjectData(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</ExceptionString></Exception></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent>
As requested, my GetProjectData method (And no, it isn't managing to write anything to my event log):
/// <summary>
///
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
[WebGet(UriTemplate = "GetProjectData/{token}", ResponseFormat = WebMessageFormat.Json)]
public GetProjectContainerResult GetProjectData(string token)
{
WriteLog("Getting project data...");
GetProjectContainerResult result = new GetProjectContainerResult();
ProjectContainer container = new ProjectContainer();
MobileAssessorAuthenticationResults authResult = ValidateToken(new Guid(token));
if (authResult == MobileAssessorAuthenticationResults.Success)
{
container.jobs = getJobs(token);
container.buildings = getBuildings();
container.floors = getFloors();
container.locations = getLocations();
result.ReturnValue = container;
result.Result = MobileAssessorOperationResults.Success;
}
else
{
switch (authResult)
{
case MobileAssessorAuthenticationResults.Error:
result.Result = MobileAssessorOperationResults.Error;
result.ResultDescription = "An error occured.";
result.ReturnValue = new ProjectContainer();
break;
case MobileAssessorAuthenticationResults.Expired:
result.Result = MobileAssessorOperationResults.Failed;
result.ResultDescription = "The specified token has expired.";
result.ReturnValue = new ProjectContainer();
break;
case MobileAssessorAuthenticationResults.Invalid:
result.Result = MobileAssessorOperationResults.Failed;
result.ResultDescription = "The specified token is not valid.";
result.ReturnValue = new ProjectContainer();
break;
}
}
return result;
}
Looking at the stack trace from your log, I think you are having issues parsing a GUID in MobileAssessorAPIService.GetProjectData method
at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at OHS.MobileAssessor.Services.MobileAssessorAPIService.GetProjectData(String token)
I would recommend that you put a break point in this method and attach a debugger to your REST service.
Based on the code you posted, the suspected line is
MobileAssessorAuthenticationResults authResult = ValidateToken(new Guid(token));
if you are not able to remotely debug this, I would recommend that you add logging just before this line to log the value of token. something like
logger.Log("paramater token = " + token);
Alternately, use wireshark to check the value of the token. once you extract the value of that guid, validate it online at http://guid.us/Test/GUID
I have a WCF service migrated to .Net framework 4.5 which is installed in IIS 7.0. I am able to browse the service in a browser. But when i refer the service in say a console application and try to call a method in it, i get the error "Access is denied". Below is the stack trace and web.config settings i am using.
System.ServiceModel.Security.SecurityAccessDeniedException was unhandled
HResult=-2146233087
Message=Access is denied.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at ConsoleApplication1.sharedservice.IShared.ProcessRequest(ProcessRequestRequest request)
at ConsoleApplication1.sharedservice.SharedClient.ConsoleApplication1.sharedservice.IShared.ProcessRequest(ProcessRequestRequest request) in c:\Users\vijayara\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\Service References\sharedservice\Reference.cs:line 214
at ConsoleApplication1.sharedservice.SharedClient.ProcessRequest(String RuleName, String RequestMessage, Int32 WaitTime, Int32 ChannelID, Int32 PassThruMode, Int32 MaxResponseSize, Int32 MaxErrorText, Int32& ActualResponseSize, String& Response, Int32& ActualErrorTextSize, String& ErrorText) in c:\Users\vijayara\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\Service References\sharedservice\Reference.cs:line 226
at ConsoleApplication1.Program.Main(String[] args) in c:\Users\vijayara\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 22
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="false" targetFramework="4.5">
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<authentication mode="Windows" />
<pages controlRenderingCompatibilityVersion="4.0">
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
<services>
<service behaviorConfiguration="Access_Shared_WCF.SharedBehavior" name="Access_Shared_WCF.Shared">
<endpoint address="" binding="basicHttpBinding" contract="Access_Shared_WCF.IShared">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http/localhost/Access_Shared_WCF/Shared" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Access_Shared_WCF.SharedBehavior">
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I have similiar issue with WCF. The problem was my appPool account doesn't have rights for generated assemblies by IIS which he use for "shadow copy".
I track it down by using procmon http://technet.microsoft.com/cs-cz/sysinternals/bb896645.aspx with filtering to IIS process name "w3wp.exe" and status to "access denied". Then call service again and check procmon output which files have this issue.
I have access deniend at c:\windows\temp\Microsoft.Generated.dll so I have remove it, call again and new one was generated and all works.
Another option is set "stronger" user identntiy to appPool like LocalService ( appPool -> advanced settings -> Indetitiy -> Predefined account -> Local service )
But solution with procmon is more fun :-)
There are many reasons why you can get this error. The times I have encountered it are when the wcf method is secured to a specific AD role:
Setting the ClientCredentials on the web service client. This can be finicky and doing certain things to the client connection can cause you to lose the credentials.
setting the InnerChannel.OperationTimeout before setting the ClientCredentials will wipe out the ClientCredentials (wierd I know, but I tested it many times).
I believe this may be an issue where the service attempts to use event log to record information. The event log doesn't exist, the Application Pool Identity pseudo-user does not have permission to create an event log. So the suggestions to use a high privileged account side step the issue by allowing it to be created. It may be possible to simply swap the user to a high account run and then switch back to regular.
Alternatively using powershell you can directly create the event log if you know what needs to be created (note it is usually very easy to view the source of any .NET application or dll to locate const string names to the usage)
New-EventLog -source "My.Name.Space" -logname "MyApplicationName"
Source: https://robertgreiner.com/wcf-azure-service-bus-access-is-denied-exception/
Hi I am using Visual studio ultimate 2012 VB.NET
I am trying to set up a new part of my website using Visual studio web forms. I want users to be able to login using there Twitter id. So I created my Twitter login app and inserted my 2 keys "Consumer key" & "Consumer secret" key in to my "AuthConfig.vb" file
I then setup my database using Visual studios "Connect to Database" It connected to my database successfully. I know this because after a message popped up telling me "connection was successful". I was then able on to use visual studio to setup a table on my database.
I confirmed the table was created by logging in to my GoDaddy server and checking the database table was showing, and it was. (So this confirms VS can connect to database.
So this is what happens,
I go to my new page I just created in VS which is this one
http://mastersworldofcomputing.com/basic-learning/Default.aspx
I then click on "Log in" which takes me to this page below.
http://mastersworldofcomputing.com/basic-learning/Account/Login.aspx
I then click on the "Twitter button" we just created (which should let me log in with Twitter id)
I am then taken to the Twitter login page, so I put username and password in and click on "Sign in".
I then get a flash screen come up telling me it is redirecting me to my page but after a couple of seconds it takes me to an error page. Showing info below.
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.ArgumentException: Invalid value for key 'attachdbfilename'.
Source Error:
Line 90: ' User has logged in with provider successfully
Line 91: ' Check if user is already registered locally
Line 92: If OpenAuth.Login(authResult.Provider, authResult.ProviderUserId, createPersistentCookie:=False) Then
Line 93: RedirectToReturnUrl()
Line 94: End If
Source File: D:\hosting\7560507\html\basic-learning\Account\RegisterExternalLogin.aspx.vb Line: 92
Stack Trace:
[ArgumentException: Invalid value for key 'attachdbfilename'.]
System.Data.SqlClient.SqlConnectionString.VerifyLocalHostAndFixup(String& host, Boolean enforceLocalHost, Boolean fixup) +907262
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +4116
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +150
System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +59
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) +122
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) +32
System.Data.Entity.Internal.LazyInternalConnection.Initialize() +131
System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName() +13
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +332
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +56
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37
System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +63
Microsoft.AspNet.Membership.OpenAuth.EFOpenAuthMembershipDatabase.GetMembershipUserName(String providerName, String providerUserId, Boolean updateLastUsed) +891
Microsoft.AspNet.Membership.OpenAuth.OpenAuthManager.Login(HttpContextBase context, String providerName, String providerUserId, Boolean createPersistentCookie) +105
Microsoft.AspNet.Membership.OpenAuth.OpenAuth.Login(String providerName, String providerUserId, Boolean createPersistentCookie) +95
Account_RegisterExternalLogin.ProcessProviderResult() in D:\hosting\7560507\html\basic-learning\Account\RegisterExternalLogin.aspx.vb:92
Account_RegisterExternalLogin.Page_Load(Object sender, EventArgs e) in D:\hosting\7560507\html\basic-learning\Account\RegisterExternalLogin.aspx.vb:48
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
My web.config file look like
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WebSite17-20121215190635;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WebSite17-20121215190635.mdf" />
</connectionStrings>
<system.web>
<compilation debug="true" strict="true" explicit="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<entityFramework>.
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
Is there anyone who can put me on the right track here so I can get past this. I must of read a hundred threads and got no where. If there is some other info that might be of use let me know
Thanks for reading.
Is it possible to define a standard ServiceHostFactory foreach 'workflow' service (xamlx)
Our customers can make there own workflows (xamlx) using a custom workflow designer. We force the workflowservices into having a WS2007FederationHttpBinding with TransportSecurity. We turn of ServiceMetadataBehavior of for the WorkflowService and finally add a DataContractResolver that does some type resolving.
The ServiceHostFactory
public class MyServiceHostFactory : WorkflowServiceHostFactory
{
protected override WorkflowServiceHost CreateWorkflowServiceHost(
System.ServiceModel.Activities.WorkflowService service,
Uri[] baseAddresses)
{
WorkflowServiceHost host = base.CreateWorkflowServiceHost(service, baseAddresses);
foreach (Uri adres in baseAddresses)
{
if (adres.Scheme == "https")
{
WorkflowCreationEndpoint endpoint = new WorkflowCreationEndpoint(
new WS2007FederationHttpBinding("IWorkflowService_ws2007FederationHttpBinding"),
new EndpointAddress(adres));
host.AddServiceEndpoint(endpoint);
PageflowDataContractResolver.AttachDataContractResolver(endpoint);
}
}
var metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
metadataBehavior.HttpGetEnabled = false;
host.WorkflowExtensions.Add(new WorkflowInstanceTracking());
return host;
}
public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses)
{
return base.CreateServiceHost(constructorString, baseAddresses);
}
protected override WorkflowServiceHost CreateWorkflowServiceHost(System.Activities.Activity activity, Uri[] baseAddresses)
{
return base.CreateWorkflowServiceHost(activity, baseAddresses);
}
}
The workflows exist in a database as Ron Jacob wrote in this blog. 'Consultants' and/or end users can create workflows using a custom tool, but each time they do they must not forget to add a serviceActivation element in the web.config which is not wanted.
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false">
<baseAddressPrefixFilters>
<add prefix="http://localhost" />
</baseAddressPrefixFilters>
<serviceActivations>
<add relativeAddress="~/Workflows/test.xamlx" service="Workflows/test.xamlx" factory="Foo.Bar.MyServiceHostFactory" />
</serviceActivations>
</serviceHostingEnvironment>
<protocolMapping>
<add scheme="https" binding="ws2007FederationHttpBinding" />
</protocolMapping>
..
I think it would be correct to rephrase your question as:
Is there a way to change the default WorkflowServiceHostFactory for a web application so that config-less xamlx activation will use my WSHF instead.
If I have understood your question correctly then I don't think there is a way to do this. I had a quick look to see if there is a place you can override it but couldn't see any. Another way to achieve this is to modify the web.config as necessary when a user uploads a new workflow. Editing the web.config in-flight should result in any currently running pulses of execution being serviced by the existing AppDomain while a new AppDomain is created to service new requests to the web application. Thus no loss of workflow processing should occur. This of course would require some testing and verification.
UPDATE
It looks like this might be possible. If you add the following to your web.config (which is from the default config for workflow activation).
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.xaml.hosting"
type="System.Xaml.Hosting.Configuration.XamlHostingSectionGroup, System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="httpHandlers"
type="System.Xaml.Hosting.Configuration.XamlHostingSection, System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</sectionGroup>
</configSections>
<system.xaml.hosting>
<httpHandlers>
<add xamlRootElementType="System.ServiceModel.Activities.WorkflowService, System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
httpHandlerType="System.ServiceModel.Activities.Activation.ServiceModelActivitiesActivationHandlerAsync, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add xamlRootElementType="System.Activities.Activity, System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
httpHandlerType="System.ServiceModel.Activities.Activation.ServiceModelActivitiesActivationHandlerAsync, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpHandlers>
</system.xaml.hosting>
</configuration>
The class ServiceModelActivitiesActivationHandlerAsync that this default config uses is implemented as follows:
internal class ServiceModelActivitiesActivationHandlerAsync : ServiceHttpHandlerFactory, IServiceModelActivationHandler
{
// Methods
public ServiceHostFactoryBase GetFactory()
{
return new WorkflowServiceHostFactory();
}
}
Then instead of using the ServiceModelActivitiesActivationHandlerAsync, provide an implementation yourself which instantiates your own WorkflowServiceHostFactory in the GetFactory method. Update the web.config above to point to your new httpHandlerType and you should be done.
I haven't tested this at all. It's possible IIS will not like the web.config overriding the system.xaml.hosting section.
We recently upgraded our web app from 3.5 to 4.0. Now after I login and load a page with Microsoft ScriptManager on it, I get:
Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
It only happens the first time, reload the page and everything works.
UPDATE: We have all Silverlight v4 projects.I found the System.Windows.dll in the C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0 directory. Why would it look for version 2.0?
Here's the entire exception (edited and removed folder paths)
Server Error in '/test' Application.
Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
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.IO.FileNotFoundException: Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 450: <UC5:PageTitle ID="PageTitle" runat="server" />
Line 451: <UC2:PageTabs ID="testPageTabs" runat="server" />
Line 452: <asp:ScriptManager ID="ScriptManager1" runat="server"/>
Line 453: <div id="step1Div" style="padding-top: 10px; padding-left: 10px" runat="server">
Line 454: <asp:ValidationSummary ID="displayValidationSummary" ValidationGroup="displayCreateEditValidationGroup" runat="server" />
Source File: c:{directories}\Pages\Administration\DisplayCreateEdit.aspx Line: 452
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +180
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +192
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +115
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +426
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit) +33
System.Web.UI.AssemblyCache.GetAjaxFrameworkAssemblyAttribute(Assembly assembly) +76
System.Web.UI.ScriptManager.get_DefaultAjaxFrameworkAssembly() +388
System.Web.UI.ScriptManager..ctor() +26
ASP.pages_administration_displaycreateedit_aspx.__BuildControlScriptManager1() in c:{directories}\Pages\Administration\DisplayCreateEdit.aspx:452
ASP.pages_administration_displaycreateedit_aspx.__BuildControlContent1(Control __ctrl) in c:{directories}\Pages\Administration\DisplayCreateEdit.aspx:9
System.Web.UI.CompiledTemplateBuilder.InstantiateIn(Control container) +12
System.Web.UI.MasterPage.InstantiateInContentPlaceHolder(Control contentPlaceHolder, ITemplate template) +87
ASP.master_master.__BuildControlContentPlaceHolder1() in c:{directories}\Master.master:28
ASP.master_master.__BuildControlmasterForm() in c:{directories}\Master.master:13
ASP.master_master.__BuildControlTree(master_master __ctrl) in c:{directories}\Master.master:1
ASP.master_master.FrameworkInitialize() in c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\zoning\dff1a5fe\99aa3a7f\App_Web_shgw15qp.4.cs:0
System.Web.UI.UserControl.InitializeAsUserControlInternal() +35
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8832342
System.Web.UI.Page.get_Master() +54
System.Web.UI.Page.ApplyMasterPage() +15
System.Web.UI.Page.PerformPreInit() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +328
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
And the system.web of our web.config:
<system.web>
<pages validateRequest="false" buffer="true" theme="Summer" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<controls>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
</controls>
<tagMapping>
<add tagType="System.Web.UI.WebControls.TextBox" mappedTagType="CleanTextBox"/>
<add tagType="System.Web.UI.HtmlControls.HtmlTextArea" mappedTagType="CleanTextArea"/>
</tagMapping>
</pages>
<compilation debug="true" targetFramework="4.0">
<assemblies>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms requireSSL="false" cookieless="UseDeviceProfile" loginUrl="~/Pages/Authentication/Login.aspx" timeout="60" defaultUrl="~/Pages/Authentication/AccountHome.aspx" slidingExpiration="true" name="sqlAuthCookie" protection="All"/>
</authentication>
<sessionState timeout="60" mode="StateServer" stateConnectionString="tcpip=localhost" stateNetworkTimeout="60" cookieless="false"/>
<customErrors mode="RemoteOnly" defaultRedirect="~/Pages/Global/DefaultError.aspx">
<error statusCode="404" redirect="~/Pages/Global/404.htm"/>
<error statusCode="403" redirect="~/Pages/Global/403.htm"/>
</customErrors>
<httpHandlers>
<add path="*js.axd" verb="*" type="ScriptCompressorHandler"/>
<add path="*css.axd" verb="*" type="CssCompressorHandler"/>
<add path="*css" verb="*" type="CssCompressorHandler"/>
<add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</httpHandlers>
<httpModules>
<remove name="WindowsAuthentication"/>
<remove name="PassportAuthentication"/>
<remove name="AnonymousIdentification"/>
<remove name="RoleManager"/>
<remove name="Profile"/>
<remove name="ErrorHandlerModule"/>
<add type="ScriptCompressorModule" name="ScriptCompressorModule"/>
<add type="CssCompressorModule" name="CssCompressorModule"/>
</httpModules>
<machineKey validationKey="{key}" decryptionKey="{key}" validation="SHA1"/>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" requestValidationMode="2.0"/>
</system.web>
See the same problem here and Microsoft Feedback/Bug report
Edit: I'm running VS 2010, XP with IIS 5.0 (I miss Win 7 at work every day :-)). We have the web app running under the local IIS instance, not Cassini. We deployed it to a test server and I did not see the exception. After I installed the C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.windows.dll to the GAC and then removed it and haven't seen the same exception, though my colleague hasn't done this and still sees it occasionally. I think it only happens when the app is restarted (which happens every time we rebuild the app when developing locally).
Sounds like one of the projects in your solution is referencing the v2 system assemblies. Make sure that all of your projects and application pools are set to use 4.0. You can set this in the project properties in Visual Studio.
(Note that you'll have to rebuild your solution with the new settings if you haven't already).
I have been having the same issues for a long time, but just found some old Silverlight Assemblies in my bin folder, removed those and voila.. error gone
Adding reference to AjaxControlToolkit.dll and adding the header
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
to the aspx that contains the script manager solved the problem for me.