Monday, 28 October 2013

CSS - To fix Gridview Header Position

Following CSS can be used to fix the header position in gridview

.fixedHeader
{
  font-weight:bold;
  background-color: #006699;
  position:relative ;
  height: 25px;
  top:expression(Sys.UI.DomElement.getBounds(document.getElementById("MainContent_dvGrid")).y-270);
  z-index: 10;
}

MainContent_dvGrid  - is  div which contain the GridView.
y- 270 => 270 value can be adjusted as per your requirement and alignment of Grid & Div.


Use this CSS in HeaderStyle of your Grid,
 <HeaderStyle CssClass="fixedHeader" ForeColor="White" Height="10px" />
                         

Monday, 15 July 2013

Microsoft.ServiceModel.Channels.Common.ConnectionException: Due to an Oracle Client limitation, the adapter failed to open a connection.

BizTalk Custom WCF Adapter Error :

Microsoft.ServiceModel.Channels.Common.ConnectionException: Due to an Oracle Client limitation, the adapter failed to open a connection. This is because either (a) ambient transaction is present and the TNS alias is longer than 39 characters, or (b) ambient transaction is present and a non-TNS based URI was used. To resolve this, use a TNS alias to connect to Oracle and make sure it is not more than 39 characters.


Solution :

In the Send Port configuration adapter I used a WCF-Custom transport type and used oracleDBbinding as binding type.
In the oracleDBbinding I changed the following propertys:

"enableBizTalkCompatibilityMode" = True (For some reasons this i set to false per default)
"useAmbientTransaction" = False

Jumped to the Message tab and uncheck the "Use Transaction" box under Transactions.

Friday, 12 July 2013

BizTalk : Runtime assembly loading issue , Could not load file or assembly



BizTalk : Runtime assembly loading issue , Could not load file or assembly



If you require a specific version of  assembly to be loaded at runtime when your BizTalk application run. This requirement could be implemented by adding a required assembly setting in BTSNTSvc.exe.config. In biztalk config file you need to specify the old and new version of assembly that need to be loaded at runtime.



Following setting could be added in your BTSNTSvc.exe.config file with proper assembly details.



Using this Binding Policy in config, we can load the any required assembly at runtime..



<runtime>

                                <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

                                                <dependentAssembly>

                <assemblyIdentity name="BTSales.DataAccess" publicKeyToken="89b653f429c47342" culture="neutral" />

                    <bindingRedirect oldVersion="2.111.7.0" newVersion="4.112.1.2"/>

            </dependentAssembly>

                                </assemblyBinding>

                </runtime>


After implementing the above changes in BtsntSvc.exe.config file, if you are still getting this error while using  BTAdmin console then  update the BTSMMCLauncher.exe.config  file same as above. This will resolve your design time assembly loading issue.


Added following  thing in BTSMMCLauncher.exe.config , Reopen your BTS Admin console.
<runtime>

                                <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

                                                <dependentAssembly>

                <assemblyIdentity name="BTSales.DataAccess" publicKeyToken="89b653f429c47342" culture="neutral" />

                    <bindingRedirect oldVersion="2.111.7.0" newVersion="4.112.1.2"/>

            </dependentAssembly>

                                </assemblyBinding>

                </runtime>

Thursday, 11 July 2013

BizTalk error : Attempted to access an unloaded AppDomain.



BizTalk errorReason: Attempted to access an unloaded AppDomain.



While accessing WCf service in one of my BizTalk application, I received the following error.



There was a failure executing the receive pipeline: "Unknown " Source: "Unknown " Receive Port: TwoWayLatencyService_RcvPort" URI: "/.svc" Reason: Attempted to access an unloaded AppDomain.



Cause : This happens when there are several Web Services with the same Application Pool, and the first is inactive for a long period of time, all the others are inactive.



Solution : after restarting the IIS server it worked.

Thursday, 27 June 2013

WCF ERROR - An unsecured or incorrectly secured fault was received from the other party


Error  :  “An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail”.
 We  got above security while accessing the WCF service deployed on our Development server

Cause  : This type of error we normally receive because of a server time skew. The remote server and the client's system time must be within (typically) 5 minutes of each other. If they are not, security validation will fail and WCF service will throw security error. The Development serve and client time difference was 10mins and Hence the service was throwing an error related to security.


Solution :
We just  have updated the server time same as client machine and then it started working.


Message security mechanism in WCF supports WS-SecurityConversation standard, which consists of establishing a session between client and server. A special request should be sent for a session to be established before any other calls. This results in getting a security token which will be used for subsequent calls. SecurityConversation mechanism has a very bad side effect - the success of conversation depends on difference between client and server system time. By default an acceptable skew between client and server is 5 minutes. If the skew is bigger than a call completes with an error. If system time on client isn't being synchronized with server then we can get (and actually get) a situation when our application stops working suddenly and start giving security related exception.

Monday, 27 May 2013

Preserve whitespace in BizTalk Transform

Preserving Whitespaces in BizTalk Transformation

Following property need to be set            r_setting.IgnoreWhitespace = false;
Full Sample code

          XsltSettings set = new XsltSettings(true, true);
        XmlReader reader;
        XmlWriter writer;
        string xmlPath_out = "D:/" + "testWhiteSpace.xml";
        //StreamWriter writer = File.CreateText(xmlPath_out);
        try
        {
            string xml_p = "testWhite_P.xml";
            string xslt_p = "xsltWhiteSpace.xsl";
            string xmlPath = Server.MapPath(xml_p);
            string xslPath = Server.MapPath(xslt_p);


            //Instantiate the XslTransform Class
            XslCompiledTransform transform = new XslCompiledTransform();
            XmlResolver secureResolver = new XmlSecureResolver(new XmlUrlResolver(), xmlPath);
            XmlReaderSettings r_setting = new XmlReaderSettings();


            transform.Load(xslPath, set, secureResolver);
            r_setting.IgnoreWhitespace = false;


            reader = XmlReader.Create(xmlPath, r_setting);
            XmlWriterSettings w_setting = new XmlWriterSettings();
            writer = XmlWriter.Create(xmlPath_out, w_setting);
            transform.Transform(reader, null, writer);


            reader.Close();
            writer.Close();
        }
        finally
        {
        }

OR

Node that need  to be added in custom XSLT file
<xsl:preserve-space elements="*"/>
http://www.w3.org/TR/xslt.html#strip  Please refer section 3.4 for link




Monday, 29 April 2013

BizTalk SendPort file name support/macro

BizTalk Send Port with File Adapter supports the following formats (macros) for the file saved.

%MessageID%
%datetime%
%SourceFileName%
%time%


Thursday, 25 April 2013

Difference between publishing schema and publishing an orchestration as a WCF Service

Difference between publishing schema and publishing an orchestration as a WCF Service

Publishing Schema as Endpoint
Publishing Orchestration as Endpoint
Orchestration Completing not require - publishing Schema as service will enable your subscribers get your Data Contracts and they can begin their development. Your subscribers don’t have to wait till you complete your business logic.
Orchestration should be completed - Publishing an orchestration requires you to get ready with the Orchestration development at first place or let your subscribers wait till you finish your orchestration development.
Orchestration will be loosely coupled- you are free to update/add new orchestration subscribing to specified message contract
Orchestration will be tightly coupled – After updating/changing orchestration need republish the Endpoint.
During publishing wizard, we need to select the schema and need to specify the request/response message.
During Publishing wizard, we don’t have to specify the schema. The orchestration input/output message will be considered as Request/Response message contract for endpoint.

Wednesday, 13 March 2013

BizTalk : Custom XSLT to reomve empty node from XML request


Using XSLT to Remove Empty Node from request.
·         To implement this, we simply create one additional step in process/orchestration.
·         Add new map with Source schema same as destination schema.
·         Use the following custom XSLT code to scan the request and remove all empty node.


Map with same schema as request and response.



Use the following xslt file with your schema namespace.

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="-- YOUR NAMESPACE --" version="1.0" xmlns:ns0="http://www.w3.org/2001/XMLSchema-instance">
    <xsl:output method="xml" indent="yes" />
    <xsl:template match="node()">
        <xsl:if test="count(descendant::text()[string-length(normalize-space(.))>0]|@*)">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()" />
            </xsl:copy>
        </xsl:if>
    </xsl:template>
    <xsl:template match="@*">
        <xsl:copy />
    </xsl:template>
    <xsl:template match="text()">
        <xsl:value-of select="normalize-space(.)" />
    </xsl:template>
</xsl:stylesheet>


 

Monday, 11 March 2013

Get the RegisteryKey value

Following sample code can be used to get RegisteryKey value based on keyPath and KeyName

public static String GetRegistryValue(String regKeyPath, String regKeyName)
{

// Create value variablestring regValue = null;
try{
// Opening the registry keyRegistryKey rk = Registry.LocalMachine;
// Open a subKey as read-onlyRegistryKey regKey = rk.OpenSubKey(regKeyPath, RegistryKeyPermissionCheck.ReadSubTree, System.Security.AccessControl.RegistryRights.FullControl);
// If the RegistrySubKey does existif (regKey != null){

// If the RegistryKey exists get its value or null is returned.regValue = (string)regKey.GetValue(regKeyName.ToUpper());}

return regValue;}

catch (Exception ex){

throw ex;}
}

Read PublicKey from Assembly using sn.exe

To get PublicKey for assembly we need to use sn.exe SKD provided by microsoft.

Run a Visual Studio 2008/10 command prompt (Visual Studio Tool + Visual Studio 2008/10 Command Prompt from the “Start” menu).
  1. Enter the following command:
sn -Tp "C:/myassembly.dll"
Where “myassembly.dll” is the name of the signed assembly.


sn -Tp (assembly full path)

Regular Expression to remove non-printable character

Following simple regular expression can be used to reomve non-printable charcter from your string or data.

Code Sample :

string str = "342343\r\n24232234234234234";
 

Regex digitsOnly = new Regex(@"[\x00-\x1F]");str= digitsOnly.Replace(str,
"");

ASCII code table

Tuesday, 26 February 2013

IIS Application browsing error " Oracle.DataAccess Incorrect Format"


Error : Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Solution :

In the IIS Manager select your server and select "Application Pools". Select the application pool used by your Web App and click on "Advanced Settings" from the right hand menu.
In the "General Section" of the advanced Settings click on the "Enable 32-bit Applications" and set it to
True.

This fix only applies to 64-bit servers that attempt to execute the 32-bit version of the Oracle Dlls.