NserviceBus throws exception when referencing a Nettiers assembly - exception

We use nettiers as a our data layer, and we recently have started looking at using NServiceBus, but we have hit a wall.
We have a windows service which hosts NSB and references our Nettiers assembly.
the service is throwing an exception when the following line is encountered.
var Bus = Configure.With().SpringBuilder()
.XmlSerializer()
.MsmqTransport()
.IsTransactional(false)
.PurgeOnStartup(false)
.UnicastBus()
.ImpersonateSender(false)
.CreateBus()
.Start();
the exceptions that is throw is:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
the loader exception message is:
Could not load file or assembly 'Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
stacktrace is:
at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at NServiceBus.Configure.<>c__DisplayClass1.<With>b__0(Assembly a) in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 122
at System.Array.ForEach[T](T[] array, Action`1 action)
at NServiceBus.Configure.With(Assembly[] assemblies) in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 122
at NServiceBus.Configure.With(IEnumerable`1 assemblies) in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 111
at NServiceBus.Configure.With(String probeDirectory) in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 101
at NServiceBus.Configure.With() in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 78
at MessageSender.Program.Main(String[] args) in C:\Development\NSBTest4\MessageSender\Program.cs:line 18
without the nettiers reference NSB works fine. Any idea what the problem is and how to solve it?
thanks.

You can exclude the nettiers dll from scanning using
With(AllAssemblies.Except("name of nettiers dll"))...

Microsoft Enterprise Library (referenced by .NetTiers) was our problem, which was in turn referencing an older version of Unity. In order to solve the problem we used the following binding redirection in the config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity.Configuration" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Alternatively, you may want to just update the Enterprise Library to the latest version.

Related

Increase RAM allowance for Windows Phone 8.1

To which file am I supposed to write information that my WP8.1 application requires 300+ MB RAM? I would like to use this setup at least for the time of developing app, later I will consider other approach, targeting all devices.
As far as I can see I have only one manifest file in my project, Package.appxmanifest, shown here. I wrote the line "m3:MinDeviceMemory"1GB"/m3:MinDeviceMemory" but it doesn't seem to be enough. I have no idea where to write ID_REQ_MEMORY_300 as recommended in msdn here.
https://msdn.microsoft.com/en-us/library/windows/apps/jj681682(v=vs.105).aspx
I see no "App" object in any of my files so I can't write any "Requirements" or "FunctionalCapability" object too. Where can I find it?
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest"xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="1cd9812c-28c9-4bc9-b45b-933beb09ad48" Publisher="CN=Štěpán" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="1cd9812c-28c9-4bc9-b45b-933beb09ad48" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Chess Openings</DisplayName>
<PublisherDisplayName>Štěpán</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
<m3:MinDeviceMemory>1GB</m3:MinDeviceMemory>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Chess_Openings.App">
<m3:VisualElements DisplayName="Chess Openings" Square150x150Logo="Assets\Logo.png" Square44x44Logo="Assets\SmallLogo.png" Description="Chess Openings" ForegroundText="light" BackgroundColor="transparent">
<m3:DefaultTile Wide310x150Logo="Assets\WideLogo.png" Square71x71Logo="Assets\Square71x71Logo.png">
</m3:DefaultTile>
<m3:SplashScreen Image="Assets\SplashScreen.png" />
<m3:InitialRotationPreference>
<m3:Rotation Preference="portrait" />
</m3:InitialRotationPreference>
</m3:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
</Capabilities>
</Package>
All this my question is wrong. There is no ID_FUNCCAP_EXTEND_MEM any more in Windows Phone 8.1 compared to Windows Phone 8. This is what I was looking for all the time.
There is no default and extended memory limit in WP8.1 but just one default memory limit and it is the high one. After checking
Windows.System.MemoryManager.AppMemoryUsageLimit
I quickly recognized that my program wasn't failing because of insufficient memory, as I thought.
I guess
<m3:MinDeviceMemory>1GB</m3:MinDeviceMemory>
(as shown in code) can limit lower memory devices from store, but this isn't what I was looking for.

how to add configuration for log4net (or any other 3rd party library) in ASP.NET 5.0

I was reading Scott Gu's blog on ASP.NET 5.0 features and one of the new feature mentioned in the blog is to use json file as configuration and elimination of Web.config file.
I have few questions around that feature.
Assume I have following log4net configuration which was previously added to Web.Config in previous version of ASP.NET
Config file
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\TestProj\\TestLog.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
How would one add sections in config.json ?
How would one convert above xml and add it to config.json?
Does 3rd Party library ( In my example log4net ) or users of the library have to add some type of custom conversion api to support json based configuration, in order to take advantage of new configuration feature provided in ASP.NET 5.0?
Recently I had the same problem with log4net. I managed to do it working as following:
Create log4net.xml file containing the configuration section for log4net
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
...
</log4net>
You can put the file in the project root folder.
And in the Startup.Startup() method you can configure the log4net providing the xml as a configuration:
public Startup(IApplicationEnvironment appEnv)
{
// ...
XmlConfigurator.Configure(new FileInfo(Path.Combine(appEnv.ApplicationBasePath, "log4net.xml")));
}
I hope this helps.
Current versions of log4net don't support Json projects, so the config needs to be in a separate xml file.

Mono WebService refuses to return json

I'm trying to create a web service using Mono 3.0.3.5 that returns json.
But so far I have been unable to get a service to return anything but xml. This appears to have been a matter of much discussion in the past, but even after checking my attempts against numerous resources here and elsewhere, I cannot tell what I'm omitting.
I created an empty ASP.NET solution, to which I added an asmx with codebehind page. As far as I'm aware, decorating the service class name with the ScriptService attribute and the method/function name with ScriptMethod and specifying Json for the ResponseFormat attribute are the only necessary steps in the code.
using System;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
namespace MonoJsonTest
{
[WebService]
[ScriptService]
public class GimmeJson : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
public string simpleTestString()
{
return DateTime.Now.ToString();
}
}
}
(I'm aware of the problems putting dates into json, I just wanted some string that would change with subsequent calls to my service)
Then I added System.Web.Extensions to the References of the project. This is built to .NET version 3.5, so I ensured that I included the 3.5 version of System.Web.Extensions.
Then the httpHandlers of web.config was modified to go through the ScriptHandlerFactory (as outlined on a couple of pages I've found)
http://vampirebasic.blogspot.com/2009/04/aspnet-ajax-in-mono.html
http://encosia.com/asmx-scriptservice-mistakes-installation-and-configuration/
A sharp eye might notice there is a difference in the web.config changes specified on the two pages. the "Culture=neutral" attribute is specified -inside- the string for the type attribute on the first page, but as an attribute of the add tag on the second. But I found that when specified the second way, there is an error upon starting the service.
My final web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation defaultLanguage="C#" debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
<customErrors mode="RemoteOnly">
</customErrors>
<authentication mode="None">
</authentication>
<authorization>
<allow users="*" />
</authorization>
<httpHandlers>
<!-- should produce json responses -->
<remove verb="*" path="*.asmx" />
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpHandlers>
<trace enabled="false" localOnly="true" pageOutput="false" requestLimit="10" traceMode="SortByTime" />
<sessionState mode="InProc" cookieless="false" timeout="20" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
<pages>
</pages>
</system.web>
</configuration>
But hitting the service (locally) from the WSDL page or with an ajax query from javascript (using JQuery library) it always returns XML. Inspecting the response headers with both Charles and Firefox debugging tools shows me a response type of text/xml.
After research, it seemed I need to request json from the service when making the call, so I set the contentType, accepts, and dataType parameters of the ajax call to specify json but this made no difference. Strangely, even the request headers show the "Accepts" parameter is still specifying xml after I have explicitly set it in the Ajax call.
Here is the ajax call (note accepts and dataType type is set to json) :
$.ajax({
url: "http://localhost:8080/GimmeJson.asmx/simpleTestString",
type: "POST",
contentType: "application/json; charset=utf-8",
accepts: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: function (data, textStatus, jqXHR) { console.log( "success" ); alert.show("success"); },
error: function(request, type, errorThrown) { console.log( "error" ); }
});
Here is the request header generated by that call (Accept is still xml):
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip,deflate
Accept-Language:en-us,en;q=0.5
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Cache-Control:no-cache
Host:localhost:8080
Origin:null
Pragma:no-cache
Proxy-Connection:keep-alive
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20100101 Firefox/14.0.1
This produces an HTTP code of 200, and this response header (note content type is xml):
Cache-Control:private
Content-Length:103
Content-Type:text/xml; charset=utf-8
Date:Thu, 09 Aug 2012 23:38:59 GMT
Keep-Alive:timeout=15, max=100
Proxy-Connection:Keep-alive
Server:Mono.WebServer2/0.2.0.0
UnixX-AspNet-Version:2.0.50727
One thing I have noticed that I'm not sure is an important point but seems odd. I browsed the System.Web.Extensions dll in Mono and noticed that a ScriptHandlerFactory did not seem to exist within it. Modifying the line in the web.config that adds the factory to specify "FOOScriptHandlerFactory" as the type did NOT produce any errors when starting the service, which would seem to indicate Mono is not reporting unfound types in the web.config. But I do not know enough about that aspect of .Net nor Mono to say that for certain. But as this factory is the lynchpin of the automatic Json serialization, this could be important.
I'm not sure what I'm omitting here. I feel like I haven't configured something on the server side correctly or it would be reporting json for the return type somewhere on the WSDL page. As you may have guessed I'm still new to online development, so my apologies if I'm overlooking Very Obvious Things.
Have you tried making the WebMethod static?
The other point I'd consider is whether the functions on the return could return 3 values instead of just one.

When you import another msbuild file, what is the order of evaluation?

I have a shared properties file shared.properties.proj
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SharedAssemblySearch>$(MSBuildProjectDirectory)\..\Shared Assemblies</SharedAssemblySearch>
<ParentDir>..</ParentDir>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblyPath Condition="Exists('$(SharedAssemblySearch)')">$(SharedAssemblySearch)</SharedAssemblyPath>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">..\SharedAssemblies</SharedAssemblySearch>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
<SharedAssemblyPath Condition="Exists('$(SharedAssemblySearch)')">$(SharedAssemblySearch)</SharedAssemblyPath>
</PropertyGroup>
</project>
I am searching for whatever level parent directory contains the directory named Shared Assemblies. or alternatively SharedAssemblies
I'd like to put this code in a central location for the sln, so that all the projects can just import it. projects in the sln are not all at the same hierarchy level.
Sample .csproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Shared.Properties.proj))\Shared.Properties.proj"
Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Shared.Properties.proj))' != '' "/>
<ItemGroup>
<Reference Include="EntityFramework">
<HintPath>$(SharedAssemblyPath)\NuGet\EntityFramework.4.3.0\lib\net40\EntityFramework.dll</HintPath>
</Reference>
</ItemGroup>
<Target Name="CheckReferencePaths" BeforeTargets="ResolveAssemblyReferences">
<Message Importance="high" Text="Doing CheckReferencePaths" />
<ItemGroup>
<SharedAssemblyPathItem Include="$(SharedAssemblyPath)" />
</ItemGroup>
<Warning Condition="!Exists('#(SharedAssemblyPathItem)')" Text="SharedAssemblyPath not found at '#(SharedAssemblyPathItem)'" />
<Warning Condition="!Exists('#(SharedAssemblyPathItem)')" Text="SharedAssemblyPath not found at '#(SharedAssemblyPathItem->'%(FullPath)')'" />
<Message Condition="!Exists('%(Reference.HintPath)')" Text="FullPath=%(Reference.HintPath)" Importance="high" />
I have this working in the main project without pushing the property group out to a satellite file that I import, but now want to make it reusable between other projects that could have shared references.
The BeforeTargets target shows this on the new attempt that is not working:
CheckReferencePaths:
Doing CheckReferencePaths
D:\projects\Team\Project\Adapters\DbAdapter\dbadapter.csproj(103,5):
warning : SharedAssemblyPath not found at ''
D:\projects\Team\Project\Adapters\DbAdapter\dbadapter.csproj(104,5):
warning : SharedAssemblyPath not found at ''
FullPath=\NuGet\EntityFramework.4.3.0\lib\net40\EntityFramework.dll
FullPath=
How can I get the project file that imports the shared to evaluate the imported project's properties before it evaluates the item groups' hintpaths. Or is the evaluation order proper, but something else in my construction is incorrect?
Your question lead me to find this valuable info on MSDN. I'm posting it here for keeping the answer self-contained.
Order of Evaluation
When MSBuild reaches an Import element, the imported project is effectively inserted into the importing project at the location of the Import element. Therefore, the location of the Import element can affect the values of properties and items. It is important to understand the properties and items that are set by the imported project, and the properties and items that the imported project uses.
When the project builds, all properties are evaluated first, followed by items. For example, the following XML defines the imported project file MyCommon.targets:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Name>MyCommon</Name>
</PropertyGroup>
<Target Name="Go">
<Message Text="Name='$(Name)'"/>
</Target>
</Project>
The following XML defines MyApp.proj, which imports MyCommon.targets:
<Project
DefaultTargets="Go"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Name>MyApp</Name>
</PropertyGroup>
<Import Project="MyCommon.targets"/>
</Project>
When the project builds, the following message is displayed:
Name="MyCommon"
Because the project is imported after the property Name has been defined in MyApp.proj, the definition of Name in MyCommon.targets overrides the definition in MyApp.proj. If, the project is imported before the property Name is defined, the build would display the following message:
Name="MyApp"
Use the following approach when importing projects
Define, in the project file, all properties and items that are used
as parameters for properties and items in the imported project.
Import the project.
Define in the project file all properties and items that must
override default definitions of properties and items in the imported
project.
Example
The following code example shows the MyCommon.targets file that the second code example imports. The .targets file evaluates properties from the importing project to configure the build.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Flavor Condition="'$(Flavor)'==''">DEBUG</Flavor>
<Optimize Condition="'$(Flavor)'=='RETAIL'">yes</Optimize>
<appname>$(MSBuildProjectName)</appname>
<PropertyGroup>
<Target Name="Build">
<Csc Sources="hello.cs"
Optimize="$(Optimize)"
OutputAssembly="$(appname).exe"/>
</Target>
</Project>
The following code example imports the MyCommon.targets file.
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Flavor>RETAIL</Flavor>
</PropertyGroup>
<Import Project="MyCommon.targets"/>
</Project>
Try to use inline task instead of shared.properties.proj file. Check my answer on this question. It was about searching for some file is the parent directories. You can adapt it to search for a parent directory.

BUG: IIS7 managed requests

(I don't know whether should I also post this question to ServerFault, since it's about IIS configuration?)
In IIS7 we can tell a module to run for managed content (thus speeding up static content serving) by:
<modules>
...
<add name="WhateverName"
type="WhateverType"
preCondition="managedHandler"
...
</modules>
But. This works fine and dandy as long as there's also a file name (with extension) in the requested URL. If it's omitted it IIS7 will think you want static content and managed modules won't run.
http://localhost/ <-- this one will skip managed handlers
http://localhost/default.aspx <-- this one will run them
If I manually set IIS7 default document, so the first one is default.aspx, I can see no difference there's no difference. To me this looks, walks and sounds like a bug. And it is a bug! Why? Because when I request for the first one, it is a managed request, isn't it. Of course it is. But IIS7 treats it as a static request. So? It's a bug. This request should be treated as managed.
How can I convince IIS7 to run managed handlers for URL requests without file names inside?
Help with thinking
Let me help you a bit with thinking: If I'd reorder system.webServer/handlers, I'm sure could solve this. Before the last StaticFile handler that points to StaticFileModule, DefaultDocumentModule and DirectoryBrowsingModule I should be running integrated asp.net handler on Directory requests. Or write my own handler, that would append default document to any directory request. I'm pretty sure one of these should solve it. But how would I have to configure/develop it?
The problem is in request-processing order. IIS7 processes requests in order specified by Handlers configuration element of IIS. By default Handlers element of the IIS configuration contains
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
at the end of the handlers. Therefore all request that not match any previously specified handler, will be processed by this handler (including folder request too).
You can remove all default handlers by using clear element in handlers configuration and specify your own request processing order.
I recommend to copy default IIS handlers configuration (C:\Windows\System32\inetsrv\config\applicationHost.config) to your web config without StaticFile handler at the end.
Then you should add specific static content handler for each static content type (jpg, gif, js, css).
<add name="StaticFile-swf" path="*.swf" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-png" path="*.png" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-gif" path="*.gif" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-jpg" path="*.jpg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-css" path="*.css" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-js" path="*.js" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
and manged handler (PageHandlerFactory) for folder requests after that.
<add name="PageHandlerFactory-Folders" path="*" verb="*" type="System.Web.UI.PageHandlerFactory" modules="ManagedPipelineHandler" resourceType="Unspecified" requireAccess="Read" allowPathInfo="false" preCondition="integratedMode" />
At the end you should also add StaticFile handler.
Here is an example.
Removing preCondition="managedHandler" or adding <modules runAllManagedModulesForAllRequests="true"> should do it. The "Preconditions" section of this page has more information.
You can use a wild card script mapping, but it's inefficient to use the managed handler to handle all requests. The static handler is much more efficient when it is appropriate.