Using In-Proc COM DLL with Azure Function - azure

Is it possible to use an In-Proc COM DLL with Azure Functions?
I am migrating my web service to Azure Functions. One of the components has a dependency on a legacy 32-bit COM DLL. This would normally require the DLL to be regsvr32-ed on the system where it will be used. As that seems not possible with Azure Functions is it possible to use such legacy implementations?
Or would it be necessary to revert to a classic cloud service to support this? (My preference would be use the Consumption service plan and benefit from "serverless" architecture.)
Steps:
Create new Azure Function App
Add new Azure Function (http trigger)
Add reference to 32-bit COM component
Call simple test method on COM component
Run locally - works fine
Publish Azure Function
Open function http path - Azure Function fails
Error log reports exception:
Could not load file or assembly 'Interop.MyCOMLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Exception while executing function: Legacy
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception
while executing function: Legacy ---> System.IO.FileNotFoundException
: Could not load file or assembly 'Interop.MyCOMLib, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
system cannot find the file specified. at async
Functions.Legacy.Run(HttpRequestMessage req,TraceWriter log) at
System.Runtime.CompilerServices.AsyncTaskMethodBuilder 1.Start[TStateMachine](TStateMachine&
stateMachine) at Functions.Legacy.Run(HttpRequestMessage
req,TraceWriter log) at lambda_method(Closure ,Legacy ,Object[] )
at
Microsoft.Azure.WebJobs.Host.Executors.TaskMethodInvoker 2.InvokeAsync(TReflected
instance,Object[] arguments) at async
Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker 2.InvokeAsync[TReflected,TReturnValue](Object
instance,Object[] arguments) at async
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker
invoker,ParameterHelper parameterHelper,CancellationTokenSource
timeoutTokenSource,CancellationTokenSource
functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan
timerInterval,IFunctionInstance instance) at async
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance
instance,ParameterHelper parameterHelper,TraceWriter
traceWriter,CancellationTokenSource functionCancellationTokenSource)
at async
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
at async
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
End of inner exception
Also, if I go to the solution's Dependencies | COM then select the Interop.Lib and select to Embed Interop Types then with this change, after publish, on calling the publushed function:
"Retrieving the COM class factory for component with CLSID {D84F92D7-FFFF-4C16-B939-EC98E3A6EBC0} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."
Thus, the challenge is how to register the COM classes with Azure Functions?

It seems that it is not possible to run regsvr32 on function app platform, when running command on Kudu console, it shows "Access Denied".
The solution is to:
1- Create small web service that use COM lib and consume its functionality and host this app on windows VM.
2- Host other part of your you code in function app and instead of reference the function APP to COM , you can call the hosted web service (and pass whatever parameters you want )
Or simply you can deploy full code on VM and don’t use Function APP.
(Thanks to Microsoft support for this answer).

There is nothing special involved in loading a COM object in a process. The process already loads a ton of random windows COM objects already. Give it a try and see if it works.
(not enough reputation to post comments)

Related

ABP framework 6.0.0 fails when deployed at Azure

Trying to deploy ABP framework 6.0.0 AuthServer at Azure, after sucessful built and run locally.
Got "HTTP Error 500.30 - ASP.NET Core app failed to start"
When trying to get some logs, using Azure Debug Console at myproject.scm.azurewebsites.net/DebugConsole I got following:
C:\home\site\wwwroot>dotnet MyProject.AuthServer.dll
[19:52:57 INF] Starting MyProject.AuthServer.
[19:53:00 FTL] MyProject.AuthServer terminated unexpectedly!
Volo.Abp.AbpInitializationException: An error occurred during ConfigureServicesAsync phase of the module Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule, Volo.Abp.OpenIddict.AspNetCore, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details.
---> Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: Access is denied.
at Internal.Cryptography.Pal.StorePal.FromSystemStore(String storeName, StoreLocation storeLocation, OpenFlags openFlags)
at System.Security.Cryptography.X509Certificates.X509Store.Open(OpenFlags flags)
at Microsoft.Extensions.DependencyInjection.OpenIddictServerBuilder.AddDevelopmentEncryptionCertificate(X500DistinguishedName subject)
at Microsoft.Extensions.DependencyInjection.OpenIddictServerBuilder.AddDevelopmentEncryptionCertificate()
at Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule.<>c__DisplayClass1_0.<AddOpenIddictServer>b__0(OpenIddictServerBuilder builder)
at Microsoft.Extensions.DependencyInjection.OpenIddictServerExtensions.AddServer(OpenIddictBuilder builder, Action`1 configuration)
at Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule.AddOpenIddictServer(IServiceCollection services)
at Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule.ConfigureServices(ServiceConfigurationContext context)
at Volo.Abp.Modularity.AbpModule.ConfigureServicesAsync(ServiceConfigurationContext context)
at Volo.Abp.AbpApplicationBase.ConfigureServicesAsync()
--- End of inner exception stack trace ---
at Volo.Abp.AbpApplicationBase.ConfigureServicesAsync()
at Volo.Abp.AbpApplicationFactory.CreateAsync[TStartupModule](IServiceCollection services, Action`1 optionsAction)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionApplicationExtensions.AddApplicationAsync[TStartupModule](IServiceCollection services, Action`1 optionsAction)
at Microsoft.Extensions.DependencyInjection.WebApplicationBuilderExtensions.AddApplicationAsync[TStartupModule](WebApplicationBuilder builder, Action`1 optionsAction)
at MyProject.Program.Main(String[] args) in D:\a\1\s\aspnet-core\src\MyProject.AuthServer\Program.cs:line 35
This say nothing to me, and when Googling around, I hit this at abp.io website: https://support.abp.io/QA/Questions/3537/OpenIddict-WindowsCryptographicException-Access-is-denied
But I can´t figure out where I shall do the changes. It feels like this should be noted in the ABP.io docs?
Do you know what can cause this, or have some ideas what can be wrong?
I was having the same issue with having the same setup as you have with the exception of deploying to azure, but it should be the same solution.
Please check this SO question:
WindowsCryptographicException: Access is denied when publishing app in Azure
The problem with OpenIddict (or rather, the goodness we're not used to) is that it is bare bones and you have to implement everything yourself.
OpenIddict must have a certificate in order to function on the server you're deploying to, and to have better security on top of whatever measures you're taking.
Basically what you will do is create a new self-signed certificate, upload it to cert store, add the thumbprint to the code and add it to one WEBSITE_LOAD_CERTIFICATES environment variable on said server.
You can add this environment variable to the code instead of hard-coding the thumbprint.
Here is a not-so-informative part of the abp.io documentation about the issue at hand:
Abp.io doc
And here is what I did in the code:
I hope this helps.

Multi-layered Blazor WebAssembly template solution (.Net 5.0) doesn't work in Azure

I've created Blazor WebAssembly solution from the template in VS2019 (target framework is .Net 5.0) and tried to run without making any changes. It runs fine locally. But being published to Azure App Service the app can't register service worker and can't open "fetchdata" page. Those are errors I could see in browser console:
Uncaught TypeError: navigator.serviceWorker is undefined
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: ExpectedStartOfValueNotFound, < Path: $ | LineNumber: 0 | BytePositionInLine: 0.
System.Text.Json.JsonException: ExpectedStartOfValueNotFound, < Path: $ | LineNumber: 0 | BytePositionInLine: 0.
---> System.Text.Json.JsonReaderException: ExpectedStartOfValueNotFound, < LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.Serialization.JsonConverter`1[[BlazorApp1.Shared.WeatherForecast[], BlazorApp1.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
Exception_EndOfInnerExceptionStack
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
at System.Text.Json.Serialization.JsonConverter`1[[BlazorApp1.Shared.WeatherForecast[], BlazorApp1.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[WeatherForecast[]](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[WeatherForecast[]](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan`1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase)
at System.Text.Json.JsonSerializer.<ReadAsync>d__20`1[[BlazorApp1.Shared.WeatherForecast[], BlazorApp1.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at System.Net.Http.Json.HttpContentJsonExtensions.<ReadFromJsonAsyncCore>d__3`1[[BlazorApp1.Shared.WeatherForecast[], BlazorApp1.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at System.Net.Http.Json.HttpClientJsonExtensions.<GetFromJsonAsyncCore>d__9`1[[BlazorApp1.Shared.WeatherForecast[], BlazorApp1.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at BlazorApp1.Client.Pages.FetchData.OnInitializedAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
What could be wrong here? What is the difference in running Blazor locally and in Azure?
It is recommand to recreate a sample project then deploy.
Update
Suggestion
Upgrade your vs2019 to lastest.
Choose .Net 5.0 .
If the problem still exists, it is recommended to replace a resource group or region for testing. If the problem no longer occurs, it is recommended to raise a support for help.
1. Create project.
2. Deploy and test.
In my case I was having some paths in my controller pointing to images. For example I was pointing to "default" images should be used in user profiles. This was working on my localhost environment, but was dropping exceptions on Azure as Azure server was not able to find these images in specified paths. This was leading to JSON exceptions mentioned in original Question above.
For example I used:
System.IO.File.ReadAllBytes(
string.Concat(this.WebHostEnvironment.ContentRootPath, "\\images\\avatar.png"));
it should have been:
System.IO.File.ReadAllBytes(
Path.Combine(this.WebHostEnvironment.WebRootPath, "images", "avatar.png"));
However this is not my main point of answer. Main point is how to find these exceptions on Azure server.
The key is to use Log Stream! Just setup your Log Stream in "App Service Logs" and then go to "Log Stream" to see any error messages appearing. It will point you towards any problems to be fixed during execution.

Binding Redirection in Azure Automation Account PowerShell Runbook

I'm in need of some help in setting up PowerShell binding redirection within an Azure Automation Account Runbook.
Essentially my Runbook calls a number of methods within two 3rd party .Net dlls, both provided by the same author. One of the dlls has a dependency on Newtonsoft.Json V12.0.1 and the other has a dependency on IdentityModel V4.0.0 which in turn has a dependency on Newtonsoft.Json V11.0.2. My Azure environment uses Windows PowerShell Desktop V5.1.15063.726. Before I do any work in my Runbook I call a function that loads all of the dlls in my imported module (the function calls the [System.Reflection.Assembly]::LoadFrom() method for each dll). I have verified that my imported dlls, including the Newtonsoft.Json.dll V12.0.1 have loaded successfully.
As expected, when Runbook execution hits a line that calls one of the 3rd party dll methods that needs the IdentityModel.dll an exception is thrown:
Exception calling "GetResult" with "0" argument(s): "Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified." System.IO.FileNotFoundException.
This is a known issue and the consensus so far seems to be that I need to create and attach an event handler in PowerShell. One of the proposed solutions can be found here. My problem is with the line that attempts to attach the handler:
[System.AppDomain]::CurrentDomain.add_AssemblyResolve($onAssemblyResolveEventHandler)
When my Runbook hits this line the following exception is thrown:
Cannot find an overload for "add_AssemblyResolve" and the argument count: "1". TargetSite: Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, System.Exception) StackTrace: at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
I can confirm that very limited testing seems to prove the code works in Windows 8.1 using the PowerShell ISE. I have searched extensively to see if there is a difference between how this code should be written in Azure and Windows Desktop, but no luck. Can anyone see what I am doing wrong? Am I missing any DLLs or using statements from my PowerShell script? If it is not possible to redirect binding in this way can anyone help with an alternative technique?
A code extract showing the creation and attachment of the event handler follows:
# Intercept resolution of binaries
$onAssemblyResolveEventHandler = [System.ResolveEventHandler]
{
param($sender, $e)
Write-Host "ResolveEventHandler: Attempting FullName resolution of $($e.Name)"
foreach($assembly in [System.AppDomain]::CurrentDomain.GetAssemblies())
{
if ($assembly.FullName -eq $e.Name)
{
Write-Host "Successful FullName resolution of $($e.Name)"
return $assembly
}
}
Write-Host "ResolveEventHandler: Attempting name-only resolution of $($e.Name)"
foreach($assembly in [System.AppDomain]::CurrentDomain.GetAssemblies())
{
# Get just the name from the FullName (no version)
$assemblyName = $assembly.FullName.Substring(0, $assembly.FullName.IndexOf(", "))
if ($e.Name.StartsWith($($assemblyName + ",")))
{
Write-Host "Successful name-only (no version) resolution of $assemblyName"
return $assembly
}
}
Write-Host "Unable to resolve $($e.Name)"
return $null
}
# Attach event handler
# This is the line that fails.
[System.AppDomain]::CurrentDomain.add_AssemblyResolve($onAssemblyResolveEventHandler)
I haven't been able to resolve the problem with getting binding redirection working in an Azure Automation Account - PowerShell runbook environment, but the author of the two 3rd party .Net dlls has kindly agreed to use NewtonSoft.Json version 11.0.2 for both dlls, so my problem disappears.

Unable to Install NServiceBus Host Windows Service

I'm attempting to follow the instructions to install the windows service host using NServiceBus.Host.exe for the VideoStore sample app. I'm following the instructions from the web site.
My application runs fine when doing an F5 session in Visual Studio. It's hosting using the console app mode for the host. When I attempt to use the command line to perform the installation, I get multiple errors.
The command line I'm running is:
NServiceBus.Host.exe /install /serviceName:"VideoStore.Sales"
/displayName:"VideoStore.Sales" /description:"Endpoint for
VideoStore.Sales"
/endpointConfigurationType:"VideoStore.Sales.EndpointConfig,
VideoStore.Sales" /username:".\MySvc" /password:"MyPassword"
NServiceBus.Production
Running this resulted in the following exception:
Initializing the installer in the Install AppDomain
Unhandled Exception: System.InvalidOperationException: Sequence
contains more than one matching element at
System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source,
Func2 predicate) at
System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at
System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at
System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at
NServiceBus.Hosting.Profiles.ProfileManager..ctor(List1
assembliesToScan, IConfigureThisEndpoint specifier, String[] args,
List`1 defaultProfiles)
It turns out, this error is caused because my application is referencing both the NServiceBus.Host assembly as well as the NServiceBus.Hosting.Azure assembly. This is because my application is being deployed both in a Windows environment as well as to an Azure worker role. I can switch between the azure emulator and the console-mode for worker roles without issue simply by changing which projects i'm starting when debugging. (Azure cloud service project vs each of the worker projects.)
I was able to resolve this by deleting the NServiceBus.Hosting.Azure.dll assembly to prevent the assembly scanning from finding it. IMHO, this is a bug. Either allow me to specify the host type explicitly or handle a scenario where multiple types are found.
This stopped the previous exception, and instead introduced a new one:
Unhandled Exception:
System.Configuration.ConfigurationErrorsException: Command line
argument 'endpointConfigurationType' has specified to use the type
'VideoStore.Sales.EndpointConfig, VideoStore.Sales' but that type
could not be loaded. at
NServiceBus.Hosting.Windows.EndpointTypeDeterminer.TryGetEndpointConfigurationTypeFromArguments(HostArguments
arguments, Type& type) in y:\BuildAgent\work
\31f8c64a6e8a2d7c\src\NServiceBus.Hosting.Windows\EndpointTypeDeterminer.cs:line
101 at NServiceBus.Hosting.Windows.Program.Main(String[] args) in
y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Hosting.Windows\Program.cs:line
38
Both that type and that assembly exist. I've even verified that .NET is loading the type via enabling fusion loader logging:
The operation was successful. Bind result: hr = 0x0. The operation
completed successfully.
Assembly manager loaded from:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under
executable
C:\Projects\Testing\NServiceBus.Azure.Samples-master\VideoStore.AzureServiceBus.Cloud\VideoStore.Sales\bin\Debug\NServiceBus.Host.exe
--- A detailed error log follows.
=== Pre-bind state information === LOG: DisplayName = VideoStore.Sales (Partial) WRN: Partial binding information was supplied for an
assembly: WRN: Assembly Name: VideoStore.Sales | Domain ID: 1 WRN: A
partial bind occurs when only part of the assembly display name is
provided. WRN: This might result in the binder loading an incorrect
assembly. WRN: It is recommended to provide a fully specified textual
identity for the assembly, WRN: that consists of the simple name,
version, culture, and public key token. WRN: See whitepaper
http://go.microsoft.com/fwlink/?LinkId=109270 for more information and
common solutions to this issue. LOG: Appbase =
file:///C:/Projects/Testing/NServiceBus.Azure.Samples-master/VideoStore.AzureServiceBus.Cloud/VideoStore.Sales/bin/Debug/
LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache
Base = NULL LOG: AppName = NServiceBus.Host.exe Calling assembly :
NServiceBus.Host, Version=4.6.0.0, Culture=neutral,
PublicKeyToken=9fc386479f8a226c.
What am I doing wrong here?
EDIT
I believe I see the issue. Basically, trying to avoid the first error where NServiceBus is resolving multiple Profiles due to the fact it's finding them in both NServiceBus.Core and NServicebus.Hosting.Azure is causing the second error.
This is because in order to load my EndpointConfig type, .NET also needs to load the NServicebus.Hosting.Azure assembly, as it implements AsA_Worker, which lives in NServiceBus.Hosting.Azure.
So be deleting that assembly, I'm preventing it from loading the EndpointConfig.
I'm still unclear as to how to resolve this. I need to get NServiceBus to stop scanning both hosting assemblies. This suggests that christof13's answer is correct, but I'm unable to get NServiceBus to ignore its own assemblies.
The root cause of this issue is that when NServiceBus enumerates profiles available, it scans all available assemblies and then does a LINQ statement to filter them down by type name.
The problem is that there are two NServiceBus.Production profiles, one defined in the NServiceBus.Host.dll, and one in the NServiceBus.Hosting.Azure assembly. Their type names are identical, and so the LINQ SingleOrDefault fails.
The suggestion to filter the assemblies searched wouldn't work because NServiceBus always loads its own assemblies. The filter only applies to my project's assemblies.
I was able to resolve this by creating a custom profile that doesn't have the same name as any other profile defined in any assemblies in my project. Something like:
public class DualCloudLocalProfile : IProfile {}
public class DualCloudLocalProfileHandler : IHandleProfile<DualCloudLocalProfile>
{
public void ProfileActivated()
{
if (LogManager.LoggerFactory is NullLoggerFactory || LogManager.LoggerFactory == null)
{
Configure.Instance.TraceLogger().ConsoleLogger();
}
}
}
public class CloudProfileLoggingHandler : IConfigureLoggingForProfile<DualCloudLocalProfile>
{
public void Configure(IConfigureThisEndpoint specifier)
{
//nothing for now
}
}
Once this was added into my project, I modified the install command to specify the new profile:
NServiceBus.Host.exe /install /serviceName:"VideoStore.Sales" /displayName:"VideoStore.Sales" /description:"Endpoint for VideoStore.Sales" /endpointConfigurationType:"VideoStore.Sales.EndpointConfig, VideoStore.Sales" /username:".\MySvc" /password:"MyPassword" VideoStore.Sales.DualCloudLocalProfile
This resolved the problem. I can now run the project as a cloud service and a NServiceBus.Host.exe hosted service, as well as deploy via the /install command for the host.
You can try to filter the assemblies with one the following methods
Configure.With(string probeDirectory)
Configure.With(params Assembly[] assemblies)
Configure.With(IEnumerable<Type> typesToScan)
By default I think that nservicebus scans all the assemblies in the folder, so if you filter with only the needed assemblies it will prevent from receiving this kind of error
http://docs.particular.net/nservicebus/the-nservicebus-host

AccessViolationException thrown when running Azure web role under the Azure emulator

I am getting a System.AccessViolationException thrown during the execution of an Azure Web Role (run on the Azure emulator, this has not been uploaded to Azure yet) when a call is made to an overridden method of an object when a local int variable is passed as one of the method parameters. The exception message is "Attempted to read or write protected memory. This is often an indication that other memory is corrupt".
The code where the exception is thrown is part of a local library that has been used for several years on live systems (not Azure) with no issues. The part that errors is as follows:
foreach (XmlDataComponent item in this.items)
{
int index = 0;
XmlNode node = item.ToXml(dataSet, xmlDocument, this, index); // Exception thrown when this call is made
...
}
The XmlDataComponent is a base class, when the code runs item is one of its derived classes. The ToXml() method is overridden in the derived classes. The exception is thrown as soon as the call is made to ToXml().
The problem is the index parameter. If I swap this to use an explicit value instead of the local variable, e.g.
item.ToXml(dataSet, xmlDocument, this, 0)
there are no errors.
Similarly, if I cast the item to its actual type e.g.
((XmlDataItem)item).ToXml(dataSet, xmlDocument, this, index))
and mark the ToXml() method in the XmlDataItem class as new instead of override there are no errors.
I have also tried calling the library from a console application rather than a web role with exactly the same data (i.e. everything the same other than running under a web role). Again, this caused no problems.
It appears that when run under the Azure emulator, accessing a local variable as a parameter to an overridden method is an issue!!!
I'm hoping this is only an issue when run under the emulator, however we still need a fix otherwise dev is more difficult.
Any suggestions or advise would be much appreciated.

Resources