Translate

Home > February 2013

February 2013

WCF wsHttpBinding sample configaration

Sunday, February 17, 2013 Category : 0

Service Config Sample

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime executionTimeout="90800" maxRequestLength="2147483647" />
  </system.web>

  <connectionStrings>
    <clear/>
    <!--<add name="MT_ConnectionString"
      connectionString="Data Source=DATASRV;Initial Catalog=report;Persist Security Info=True;User ID=me;Password=Me2012"
      providerName="System.Data.SqlClient" />-->
    <add name="MT_ConnectionString"
      connectionString="Data Source=PGTONMOY-PC\NOKIA;Initial Catalog=HShopMT;Persist Security Info=True;User ID=sa;Password=data"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.serviceModel>
    <services>
      <service name="MT_WService.MTService" behaviorConfiguration="ServiceBehavior">
        <!-- Service Endpoints -->
        <endpoint address="MTService" behaviorConfiguration="EndPointBehavior" binding="wsHttpBinding"
            contract="MT_WService.IMTService" bindingConfiguration="WSHttpBinding_IMTService">
          <identity>
            <dns value="apps.mediasoftbd.com" />
          </identity>
        </endpoint>
        <!-- This Endpoint is used for genertaing the proxy for the client -->
        <!-- To avoid disclosing metadata information, set the value below to false and
       remove the metadata endpoint above before deployment -->
        <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding" />
        <host>
          <baseAddresses>
            <add baseAddress="http://127.0.0.1/MTService/"/>
          </baseAddresses>
        </host>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="1909600"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="EndPointBehavior">
          <dataContractSerializer maxItemsInObjectGraph="1909600"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IMTService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:50:00" sendTimeout="00:50:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2000000000" maxReceivedMessageSize="2000000000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="00:50:00" enabled="false" />
          <security mode="None">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 
 
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
 
</configuration>

Application Configuration sample

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <connectionStrings>
    <add name="MT_ConnectionString"
      connectionString="Data Source=NOKIA;Initial Catalog=ShopMT;Persist Security Info=True;User ID=sa;Password=sa21"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IMTService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:50:00" sendTimeout="00:50:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2000000000" maxReceivedMessageSize="2000000000"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
          allowCookies="false">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="00:50:00"
            enabled="false" />
          <security mode="None">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="false"
              algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost/MT/MTService.svc/MTService"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMTService"
          contract="MTService.IMTService" name="WSHttpBinding_IMTService"
                behaviorConfiguration="EndPointBehavior">
        <identity>
          <dns value="apps.mediasoftbd.com" />
        </identity>
      </endpoint>
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="EndPointBehavior">
          <dataContractSerializer maxItemsInObjectGraph="1909600"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

Exception from HRESULT: 0x80070057 (E_INVALIDARG)

Monday, February 11, 2013 Category : 0


Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

 
[FileLoadException: Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +416
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190

[ConfigurationErrorsException: Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11224200
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +388
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +232
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +48
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +210
   System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +191
   System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +54
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +295
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +476
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +116
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +175
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +52
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +50
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +425
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +263

 

Solution:
This method worked for me,

-Stop IIS server or VS

-go to:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

-and delete all folders in this directory

-launch IIS or VS

What is Reflection in .net

Category : 0

The main value of Reflection is that it can be used to inspect assemblies, types, and members. It's a very powerful tool for determining the contents of an unknown assembly or object and can be used in a wide variety of cases.
Opponents of Reflection will cite that it is slow, which is true when compared to static code execution--however Reflection is used throughout the .NET framework, and provided that it's not abused it can be a very powerful tool in the toolkit.
Some useful applications:
  • Determing dependancies of an assembly
  • Location types which conform to an interface, derive from a base / abstract class, and searching for members by attributes
  • (Smelly) testing - If you depend on a class which is untestable (ie it doesn't allow you to easily build a fake) you can use Reflection to inject fake values within the class--it's not pretty, and not recommended, but it can be a handy tool in a bind.
  • Debugging - dumping out a list of the loaded assemblies, their references, current methods, etc...

    http://stackoverflow.com/questions/1458256/why-use-of-reflection-in-net-c-sharp-code-are-recommended


The only place I've used the Reflection stuff in C# was in factory patterns, where I'm creating objects (in my case, network listeners) based on configuration file information. The configuration file supplied the location of the assemblies, the name of the types within them, and any additional arguments needed. The factory picked this stuff up and created the listeners based on that.

http://stackoverflow.com/questions/429962/when-do-you-use-reflection-patterns-anti-patterns


What is .NET Reflection?

.NET Framework's Reflection API allows you to fetch type (assembly) information at runtime programmatically. We can also achieve late binding by using .NET Reflection. At runtime, the Reflection mechanism uses the PE file to read information about the assembly. Reflection enables you to use code that is not available at compile time. .NET Reflection allows an application to collect information about itself and also to manipulate on itself. It can be used effectively to find all types in an assembly and/or dynamically invoke methods in an assembly. This includes information about the type, properties, methods, and events of an object. With Reflection, we can dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields and properties. We can also access attribute information using Reflection.
Using Reflection, you can get any kind of information which you can see in a class viewer; for example, information on the methods, properties, fields, and events of an object.

http://www.codeproject.com/Articles/55710/Reflection-in-NET

Crystal report error (Load report failed) in asp.net

Saturday, February 9, 2013 Category : , 0

There are various reason for this error. in the following list all may cause this problem


1.

public static ReportDocument rep = new ReportDocument();
   protected void Page_UnLoad(object sender, EventArgs e)
   {
       this.CrystalReportViewer1.Dispose();
       this.CrystalReportViewer1 = null;
       rep.Close();
       rep.Dispose();
       GC.Collect();
   }
 
 
2. crystal report assemblies installed on your machine do not reflect the assemblies you have on your web.config

3. crystal version installed on the server is different with the one you want to invoke from your site

4. application pool where your reports run is not set to LOCAL SERVICE

5. read and write permission is not enabled on your root folder

6. crystalreportviewer folder is not copied to your operating folder. 
 
 
7. lack of permission in following  directory

The fix: When Crystal Reports opens a file, it uses the Windows temporary folder (typically C:\Windows\Temp\) as a scratch-pad. You need to give Crystal Reports explicit permission to read and write to this folder.

How-to: Under XP, ASP.NET runs CR under ASPNET; with most of the Windows Server flavors, CR runs as NETWORK SERVICE. Make sure that this identity has permission to read and write to the Windows temporary folder.
1. Ensure the RPT file name is correct. Filename must be a fully qualified valid path name (such as C:\MyApp\MyReport.rpt).
2. The ASPNET account has permissions to open the file.  Make sure the folder containing the file and the file itself has the same permissions as your application folder.


But still i don't found any solution
next i tried to discover my iis different settings. and i found an interesting option.
* select your application pool for your apllication or website
* Click on Recycling (Right side panel)
* Reduce the value of Regular time interval 1740 to 20 min or set your desire value you want
* this  will release any resource hold by iis.

And This has help me to overcome this error

Powered by Blogger.