Friday, July 29, 2011

Visual Studio LightSwitch

Visual Studio LightSwitch seems to be a real productivity booster for some applications. See one demo here how even a business user can create the application.

Cheers
Rohit Sharma

Friday, July 22, 2011

Error: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem

Charan: Hey Pal I am getting this weird error not sure what is wrong everything was working fine few hours ago and now I am unable to start the 32-bit BizTalk host instances. I have even repaired the BizTalk installation and still getting the same error.


Rohit: Have you done any recent changes to the machine.

Charan: Yes I have installed one BizTalk application exported from the other machine and this application get its connection string from the configuration file of BizTalk so I have modified the 'BTSNTSvc.exe.config'.

Rohit:  Let me see the 'BTSNTSvc.exe.config' file.
I got the issue you have not closed the tag as shown below.


 Charan: Oh what a silly mistake it fixed the issue. Now I can start the orchestration instance.

Cheers
Rohit Sharma

Tuesday, July 19, 2011

How to remove leading zeros from the value of element in a map

Charan: I have one additional requirement to my old problem mentioned here. Now I want to remove the leading  Zeros for the value of Element1 in addition to finding the existence of this optional element in input schema. Is there any easy way to do it.

Rohit: hmmm yes we can do it using the scripting functoid and simple C# code. Let me show you how.

Step1: Add new scripting functoid.

 
Step2: Configure Functoid Script use Inline C# as Script Type: and use the following simple C# code to remove the leading zeros in string:

public string RemoveLeadingZeros(string param1)
{
      string result=param1;
      if(param1.StartsWith("0"))
      {
          result=param1.TrimStart(new char[]{'0'});        
      }  
      return result;
}


Step3: Modify the existing scripting functoid to use this code to remove the leading zeros:

<Element xmlns:p="http://CheckNodeExistenceInMap.InputSchema_XML">
    <xsl:choose>
        <xsl:when test="/p:Record/Element1">
            <xsl:value-of select="userCSharp:RemoveLeadingZeros(string(/p:Record/Element1))" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="/p:Record/Element2" />
        </xsl:otherwise>
    </xsl:choose>
</Element>


Cheers
Rohit Sharma

Saturday, July 16, 2011

Is it possible to use the extension method in Expression shape of BizTalk 2010

Charan: I have created one extension method  to count the no of words (separated by character space ,  dot or question mark)  in a string by following this link.

Now I want to know is it possible to use the extension method in Expression shape of BizTalk 2010http://i3.social.s-msft.com/Forums/resources/images/trans.gif?cver=1864.870%0d%0a.

This is the extension method I have created.

 And this is test code to execute test it.


Rohit: The answer is no and yes

In your test code you have declared the namespace (DemoExtensionMethodForString) for the static class (MyExtensions) created for the extension method (WordCount) by specifying it with the using statement and you can't use the using statement in the expression shape so you can't use it in the same way as you have used in your test code i.e. as instance method of string variable.

But your extension method is just a static method created in a static class so can be executed it in expression shape as shown below:

Any comments or suggestions are welcome.

Cheers
Rohit Sharma


Friday, July 15, 2011

Checking if the optional element exists or not in Mapping

Charan: I have a problem I have one schema which has one optional filed 'Element1' and I need to map this schema to other schema but the twist is if this optional filed is not present in the input schema then I need to map other filed 'Element2' to the output schema.
 Input schema with optional filed 'Element1'

 Output Schema

Rohit: You can do this using the Scripting functoid as shown below:
 Drag scripting functoid

 Configure scripting functoid

Following is the XSLT used for scripting functoid.
<Element xmlns:p="http://CheckNodeExistenceInMap.InputSchema_XML">
    <xsl:choose>
        <xsl:when test="/p:Record/Element1">
            <xsl:value-of select="/p:Record/Element1" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="/p:Record/Element2" />
        </xsl:otherwise>
    </xsl:choose>
</Element>

Note: If the value of property 'Element FormDefault' for the source schema is 'Qualified' then the alias for namespace need to be used for each element as mentioned below:

<Element xmlns:p="http://CheckNodeExistenceInMap.InputSchema_XML">
    <xsl:choose>
        <xsl:when test="/p:Record/p:Element1">
            <xsl:value-of select="/p:Record/p:Element1" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="/p:Record/p:Element2" />
        </xsl:otherwise>
    </xsl:choose>
</Element> 



Cheers
Rohit Sharma

Monday, July 4, 2011

Error: " The underlying connection was closed: An unexpected error occurred on a receive."

Moving the original post

Event Type:   Error
Event Source: BizTalk Server 2006
Event ID:       5754
Description:
A message sent to adapter "HTTP" on send port "<SendPortName>" with URI "<URL>" is suspended.
 Error details: The underlying connection was closed: An unexpected error occurred on a receive.

You can get the similar error for SOAP adapter too.

Cause
On production environment this error was occurring randomly once or twice in a month. After lot of investigation I came to know that the AppPool was getting recycled before Web Page can respond to the request.
Though there are no of reasons for AppPool recycle but in this case the IIS was hosted on a machine having sufficient resources(memory,CPU). I figured out that the app pool used for web application was configured to get recycled after 1740 minutes (which is default setting when you create new App Pool).

Resolution
Open the Internet Information Services (IIS) Manager go to Application Pool  and open the properties of the required application pool. Uncheck the "Recycle worker processes (in minutes):" check box.

Cheers
Rohit Sharma

Error: "The HTTP send adapter cannot complete the transmission within the specified time"

Moving the original post

Event Type:   Error
Event ID:       5754
Description:
A message sent to adapter "HTTP" on send port "<SendPortName>" with URI "<URL>" is suspended.
Error details: The HTTP send adapter cannot complete the transmission within the specified time.

Cause
This error occurred for Solicit-response send port when the HTTP adapter does not receive the response within the time specified for Request timeout. The default value for Request timeout is 0 and in this condition the BizTalk Messaging Engine calculates the time-out based on the request message size.

Resolution
Set the value of Request timeout for send handler created for HTTP adapter then this change will affect all the send ports. or
You also have the option to set the value of Request timeout for a particular send port in HTTP Transport Properties.

Cheers
Rohit Sharma

Error: "Could not load file or assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies."

Moving the original post

When trying to browse my WCF service using .Net Framework 4.0 and hosted in IIS 6.0 I was getting this error in the event viewer.

Event Type:         Error
Event Source:     ASP.NET 4.0.30319.0
Event Category:  None
Event ID:            1325
Description:
Failed to initialize the AppDomain:/LM/W3SVC/1381374284/Root/RetrieveDataService
Exception: System.IO.FileLoadException
Message: Could not load file or assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Access is denied.
StackTrace:    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.InternalCreateInstanceWithNoSecurity(String assemblyName, String typeName)
   at System.AppDomain.InternalCreateInstanceWithNoSecurity(String assemblyName, String typeName)
   at System.Activator.CreateInstance(AppDomain domain, String assemblyName, String typeName)
   at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
   at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)

Resolution
Because the Application Pool was using the identity NETWORK SERVICE so I had to give the IIS_WPG group (which contains NETWORK SERVICE) read/write access to my web root directory.

Cheers
Rohit Sharma