SignalR Scaleout with SQL Server raising Nullable object must have a value - signalr

I want my SignalR app to deploy in webfarm environment, so I went with signalR Scaleout with SQL server option.
I tested by pointing to my local DB and it is working fine. But when I pointed to my PROD db all the required DB tables and SignalR schema created. But when the client hits for the first time to create hub proxy it is failing and in next attempt it is connecting.
Below is the fatal exception I am getting from SignalR.SqlServer
Nullable object must have a value.
at Microsoft.AspNet.SignalR.SqlServer.SqlReceiver.Receive(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.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

I just ran into this issue and after looking at the source found that the Messages_0_Id needed to have a row added to it if it was empty.
if((select count(*) from [SignalR].Messages_0_Id) = 0)
begin
Insert into [SignalR].Messages_0_Id (PayloadId) values (1)
end

The issue was due to me using Web Deploy and enabling the DB migrations from EF on deploy.
Deleting the database and unchecking the option made it work properly.

Related

Operation is not valid due to the current state of the object. with Web API

I am getting this exception "Operation is not valid due to the current state of the object." in my server when trying to access one of Web API methods. But the other methods are working fine. And the API is working fine with all methods in the Dev Environment(Local).
And Most important thing is it is not consistent...some times I am able to get the result from the API...sometimes doesn't.
And my log file says the following error
System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Oracle.DataAccess.Client.OracleDataReader.get_IsEOF()
at Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
This is the error I am getting when I hit the Method from the client. Please let me know how to fix this issue.
Fixed...It is due to some unreleased resources. Used the "Using" Clause for the database accessing code. Now it is fixed.

Inner SecurityException while using XmlSerializer

While creating a custom Sharepoint web service I received an error while attempting to serialise a class for transmission.
There are no errors with my serializable classes. They are structured in a manner I have used before and can be serialised successfully on a local test environment, the issue only arises when the Sharepoint web service has been deployed.
System.InvalidOperationException was caught
Message=There was an error generating the XML document.
Source=System.Xml
StackTrace:
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces)
at SPServiceExtensions.DTOSerializerHelper.SerializeDTO(SharepointDTO dto)
InnerException: System.Security.SecurityException
Message=Request failed.
Source=xo46jp-i
StackTrace:
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSharepointDTO.Write4_SharepointDTO(String n, String ns, SharepointDTO o, Boolean isNullable, Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSharepointDTO.Write5_SharepointDTO(Object o)
InnerException:
The inner SecurityException was unfamiliar. What is causing this Exception?
ASP.NET uses different trust levels for it's security policies. This is so applications cannot access the data from other unrelated applications.
Microsoft Sharepoint has two additional code access levels of its own and by default runs on WSS_Minimal.
As the webservice is operating as a local application on the Sharepoint server it requires Full Trust
However Microsoft discourages applying full trust willy nilly. I gather that it potentially allows other applications to call your code which has the potential of being used maliciously to exploit the system.
So a better way to prevent the SecurityException is to modify the projects AssemblyInfo.cs and add this attribute [assembly:AllowPartiallyTrustedCallers] to it.
Microsoft's article on Code Access Security.

aspnet_regsql problem with creating Session tables in mssql

I'am using session state handling in ASP.NET by MSSQL server with:
sessionState mode="SQLServer"
in web.config. Locally I used aspnet_regsql with no problems but while trying to do same on production server it throws exception at me (* - are masked data):
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regsql.exe -S somehostserver.com -U _admin -P _password -ssadd -sstype c -d mydb
Start adding session state.
.
An error occurred during the execution of the SQL file 'InstallSqlState.sql'. Th
e SQL error number is 229 and the SqlException message is: The EXECUTE permissio
n was denied on the object 'sp_delete_job', database 'msdb', schema 'dbo'.
If the job does not exist, an error from msdb.dbo.sp_delete_job is expected.
SQL Server: *
Database: [*]
SQL file loaded:
InstallSqlState.sql
Commands failed:
/* Drop all tables, startup procedures, stored procedures and types. */
/* Drop the DeleteExpiredSessions_Job */
DECLARE #jobname nvarchar(200)
SET #jobname = N'***' + '_Job_DeleteExpiredSessions'
-- Delete the [local] job
-- We expected to get an error if the job doesn't exist.
PRINT 'If the job does not exist, an error from msdb.dbo.sp_delete_job is expect
ed.'
EXECUTE msdb.dbo.sp_delete_job #job_name = #jobname
SQL Exception:
System.Data.SqlClient.SqlException (0x80131904): The EXECUTE permission was deni
ed on the object 'sp_delete_job', database 'msdb', schema 'dbo'.
If the job does not exist, an error from msdb.dbo.sp_delete_job is expected.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolea
n breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception
, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cm
dHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, Tds
ParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName,
Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult res
ult, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Web.Management.SqlServices.ExecuteFile(String file, String server,
String database, String dbFileName, SqlConnection connection, Boolean sessionSta
te, Boolean isInstall, SessionStateType sessionStatetype)
Using SQL scripts causes similar errors. What should I do ?! Hosting owner suggests "make backup on ur machine and place it in production", but This causes another problems...
Any suggestions !? Or Iam forced to craft by hand all scripts for tables and procedures ?!
Best regards
It seems that the user is missing the "RSExecRole" role in the Master and MSDB system databases. Reporting Services uses a predefined database role called "RSExecRole" to grant report server permissions to the report server database.
The "RSExecRole" role is created automatically with the report server database. However, when you move a report server database to a new or different SQL Server Database Engine, must re-create the role in the Master and MSDB system databases.
Here is a link reference to how to create the "RSExecRole":
http://technet.microsoft.com/en-us/library/cc281308.aspx

Recycle windows workflow after changes on workflow activity

I used WWF on my web project, on this project I have several workflows and visitor will fill forms and then form will post to technical people to do their job and some other state ...
When I change workflow and create new activity or state , when run ( continue ) all workflows that persist on db before changes , will throw errors.
Server was unable to process request. ---> System.InvalidOperationException: Workflow with id "82b0cb6c-d6b7-43cd-9071-04a1078954ec" not found in state persistence store.
at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveInstanceState(Guid instanceStateId, Guid ownerId, DateTime timeout)
at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.LoadWorkflowInstanceState(Guid id)
at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance)
at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance)
at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)
at System.Workflow.Activities.WorkflowWebService.Invoke(Type interfaceType, String methodName, Boolean isActivation, Object[] parameters)
how can I recycle old workflows after changes?
Thanks
Your error looks pretty specific there. The workflow with your particular GUID doesn't exist.
Changing a workflow definition does not change existing workflows. They will continue to execute their predetermined definitions unless you initiate an actual change process on them. You'll want to dig into Dynamic Workflow Updates if this is what you want to accomplish.

BizTalk BRE InvalidCastException

I have configured a new VM (MS Virtual Server running Windows Server 2003) as a copy of an existing VM hosting BizTalk server 2006. I have run into a problem with BRE processing. The policy is deployed and vocabulary published exactly as on the working VM.
An orchestration calls a helper component which in turn makes use of the BRE components. The last line in the helper component that seems to execute is:
Policy workflowPolicy = new Policy(policyName)
I have pasted the stack trace from the event log below:
Exception type: InvalidCastException
Source: Microsoft.RuleEngine
Target Site: Int32 GetInt32(System.String, Int32)
The following is a stack trace that identifies the location where the exception occured
at Microsoft.RuleEngine.Configuration.GetInt32(String key, Int32 defaultValue)
at Microsoft.RuleEngine.ReteTranslator.RuleSetToReteTranslatorImpl.Translate(RuleSet ruleset, Int32 duration)
at Microsoft.RuleEngine.ReteTranslator.RuleSetToReteTranslator.Translate(RuleSet ruleset, Int32 duration)
at Microsoft.RuleEngine.RuleEngine..ctor(RuleSet ruleSet, Boolean doOptimizations)
at Microsoft.RuleEngine.RuleEngineCache.Allocate(String rulesetName, Int32 majorRevision, Int32 minorRevision, TrackingConfiguration& trackingConfig)
at Microsoft.RuleEngine.RuleEngineCache.Allocate(String rulesetName, TrackingConfiguration& trackingConfig)
at Microsoft.RuleEngine.Policy..ctor(String policyName)
at Tesco.BRE.Services.PolicyServices.Direct.OrderWorkflowServices.Commands.GetNextTaskList.Execute()
at Tesco.DataSources.Integration.Common.CommandBase.CommandDecorators.CommandLoggingDecorator`1.Execute()
at Tesco.DataSources.Integration.Common.CommandBase.CommandUtilities.GetCommandResponse[T](CommandBase`1 command)
at Tesco.BRE.Services.PolicyServices.Direct.OrderWorkflowServices.OrderWorkflowOperations.GetNextTaskList(String currentTaskName, String currentTaskStatus, XmlDocument order)
at Tesco.Direct.OrderManagement.Orchestrations.FollowTaskResult.segment2(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception&
It looks like Microsoft.RuleEngine.Configuration.GetInt32 is being passed a value that cannot be cast to an Int32?
I have tried un-configuring / re-configuring the BRE. As far as I can tell everything on the new server is configured exactly as per the working server.
Any help, gratefully receive - I've been stuck with this all day!
If one follow the stack trace one could read "cache" and "tracking". I would try to restart the host and uncheck any rule tracking in HAT.
Thanks for your response Martin. I have now fixed the issue. The problem was user error (mine) in making a registry change. I had to create a reg setting as follows
HKLM\SOFTWARE\Microsoft\BusinessRules\3.0\StaticSupport (DWORD), value 2
in order to enable the BRE to make use of static methods. This is described at: http://technet.microsoft.com/en-us/library/dd298814.aspx
Although I had made the addition when configuring the server, I had inadvertently used a string rather than a dword. Since this cost me over a day to figure out - I won't be making the same mistake any time soon!

Resources