in

Community Blogs

Blogs of different SQL/Developers Community Members

This Blog

Syndication

DamirDobric

listopad 2009 - Posts

  • DTC Transaction Manager (Exception from HRESULT: 0x80070005)

    Error Description

    When working with Ado.Net Entity Framework, you may get following error:

    Exception: The underlying provider failed on Open.

       at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)

       at System.Data.EntityClient.EntityConnection.Open()

       at System.Data.Objects.ObjectContext.EnsureConnection()

       at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)

       at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()

       at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)

       at System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1[TResult](IEnumerable`1 sequence)

       at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)

       at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.ExecuteSleep(Expression expression)

       at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)

       at Daenet.PresentationManagement.Database.PresentationManagementDal.GetLinkedContent(Guid slideId) in C:\nstorandt\Schmid\Daenet.PresentationManagementSolution\Daenet.PresentationManagementApi\Database\PresentationManagementDal.cs:line 396

    InnerException ->Exception: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

       at System.Transactions.Oletx.IDtcProxyShimFactory.ConnectToProxy(String nodeName, Guid resourceManagerIdentifier, IntPtr managedIdentifier, Boolean& nodeNameMatches, UInt32& whereaboutsSize, CoTaskMemHandle& whereaboutsBuffer, IResourceManagerShim& resourceManagerShim)

       at System.Transactions.Oletx.DtcTransactionManager.Initialize()

       at System.Transactions.Oletx.DtcTransactionManager.get_ProxyShimFactory()

       at System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte[] propagationToken)

       at System.Transactions.TransactionStatePSPEOperation.PSPEPromote(InternalTransaction tx)

       at System.Transactions.TransactionStateDelegatedBase.EnterState(InternalTransaction tx)

       at System.Transactions.EnlistableStates.Promote(InternalTransaction tx)

       at System.Transactions.Transaction.Promote()

       at System.Transactions.TransactionInterop.ConvertToOletxTransaction(Transaction transaction)

       at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)

       at System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transaction transaction, Byte[] whereAbouts)

       at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)

       at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)

       at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)

       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)

       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)

       at System.Data.SqlClient.SqlConnection.Open()

       at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)

    Solution

    To solve the problem the machine which tries to communicate with database which is hosted at another machine has to be trusted for delegation. Enable the machine which shows the error to be trusted for delegation. Note that DTC service user has to be in this case NETWORKSERVICE user.

  • How to connect to TFS 2008 from VS 2010?

    By connecting to TFS 2008 from within Visual Studio 2010 you might experience few problems. To connect successfully just type the name of the TFS server. Do not change any other field!


    image

  • Welcome Visual Studio 2010 Ultimate Beta 2

    I’m proud to announce that VS 2010 Ultimate BETA 2 is online now. The new version should provide hundreds of useful features for developers. I’m just a bit disappointed that MS guys didn’t decide to change design welcome page which is shown after the setup is started:

    image

    It is now 20 years to me of trying of VS Beta-s. In these years design of the welcome screen shown above has been changed from time to time. Unfortunately the semantic seems to remain for ever.

    PS. This is setup screen on the new fresh Win7 machine.

  • Workflow 4.0 and content based correlation in .NET 4.0 Beta 2

    Before one correlation can be used we first need to define the correlation handle. To do this click on Variables tab (bottom left in WF designer) of the activity which is the parent of receive shape, which will initialize the correlation. Enter the name of variable (in this case “correlator”) and set the type on CorrelationHandle.

    image

    Now, click on the receive message shape and in the list of properties should appear following three values:

    • Correlates On
    • Correlates with
    • Correlation Initializes

    image

    First of all the correlation handle has to be initialized. This can be done for example at the very first receive message shape. Click CorrelationInitializers and following window will appear:

    image

    In this window you will see handle as already initialized. This is automatically done when you drag the Receive/SendResponse shape to designer. Create new correlation initializers (see “correlator”). Select Query Correlation Initializer. Then select the property which should initialize the correlator:

    image

    In my case I selected OrderID, which is a property of data contract OrderRequest. That mean we have initialized the correlation handle on property OrderID of the message OrderRequest. Please note that there is a property “CanCreateInstance” of the receive shape, which should be set on TRUE if the receiving message of this shape has to start the new workflow.

    Now I select some other receive shape which requires the correlation.

    image

    The property CanCreateInstance of this shape has to be set on FALSE, because this shape will not start the new instance of the workflow. Instead, this shape will post the message to already running WF-Instance. This is exactly the crucial point. How the WF-runtime can now to which instance the message will be posted?
    The answer is: “content based correlation”. To make this possible set the property CorrelatesWith (of second receive shape) on the name of correlation handle called. In our case is this “correlator”-variable.

    Now, select the value of Correlates With as shown at the next picture:

    image

    Note that we now correlate property OrderID of message ConfirmationRequest, which is different one than OrderRequest.OrderID. Briefly that mean: “The message of type ConfirmationRequest will be posted to running instance of Workflow which has the same OrderID in as the message OrderRequest which has started the workflow instance.

     

    That’s it :)

  • IIS 7.5 and “Always Running” Web Applications

    IIS 7.5 which is ships with Windows Server 2009 R2 and Windows 7 provides a new feature for Web Applications. This feature allows one to install a Web Application which is not initialized after receiving of the first request started. Instead such application is started immediately after it is configured to run in this mode which is called “Always Running”. Always Running is more an attribute of the application pool than of application. The same feature is supported by ASP.NET 4.0. In ASP.NET 4.0 context it is simply called “Auto-Start”.

    To setup the pool set the attribute startMode to AlwaysRunning of the IIS config file C:\Windows\System32\inetsrv\config\applicationHost.config:

    <applicationPools>
        <add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
    </applicationPools>

     

    Immediately after saving of the changed config-file the new process W3WP.EXE will be started.

    If you want to specify which application will be auto=startable see following example:

    <sites> 
         <site name="SomeSite" id="1"> 
              <application path="/" serviceAutoStartEnabled="true" />
         </site>
    </sites>

     

    Additionally you can even implement some kind of reloading functionality called Auto Start Provider. To do that implement the interface IProcessHostPreloadClient .
    While the application is starting one specific method of that provider will be called to do whatever on start-up. While the application is starting app, no request will be executed by IIS.

    public class MyStartUpCode : System.Web.Hosting.IProcessHostPreloadClient
    {

    public void Preload(string[] parameters) 
    {
        . . .

      }

    }

     

    To register the custom Auto Start Provider code:

    <serviceAutoStartProviders>
         <add name="MyAutoStartProvider" type="MyStartUpCode, TheNameOfMyAssembly" />
    </serviceAutoStartProviders>

    To activate it do following:

    <sites> 
         <site name="SomeSite" id="1"> 
              <application path="/" serviceAutoStartEnabled="true" serviceAutoStartProvider=”MyAutoStartProvider” />
         </site>
    </sites>
    Posted lis 11 2009, 10:19 by anonymous
    Filed under:
  • Workflow 4.0 Content Based Correlation error

    When working with WF 40 and content based correlation you may get following error:

    The execution of an InstancePersistenceCommand was interrupted by a key collision. The instance key with value '300a1ad8-d985-56dc-4075-b45e1aa1faa1' could not be associated to the instance because it is already associated to a different instance.

    Remark: The key value (guid in example above) is application specific and in your case the same value will for sure not appear.

    This message appears when you initialize the workflow and the correlation token based on some property value in the message, but the workflow with the same property value has already been started.

     

    For example, you have receive shape which starts with message and property OrderID=100. The same shape initializes the content based correlation based on the same property. On first call the workflow will be started and at some later point of time persisted. If the client sends the same message now (OrderID=100) the workflow will fail, because it has already been started.

     

    Note also: If the workflow ends up before new message with the same ID comes, all will work fine.

Copyright of SQL/Developers Community
Powered by Community Server (Commercial Edition), by Telligent Systems