Calling a WCF Service from SQL CLR Stored Procedure - sql

I have created a SQL CLR Stored Procedure which will call a WCF Service. I have managed to get all the correct DLL's loaded into SQL Server to get this to work however I now have following error message:
System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for system.serviceModel/extensions: Could not load file or assembly 'System.IdentityModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) (C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config\machine.config line 185)
System.Configuration.ConfigurationErrorsException:
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String ...
I found this posting on the web but I don't know how to update the GAC or whether its actually the fix for the problem: (Invoking a WCF Service from a CLR Trigger)

Look at Niels Berglund's blog post: http://nielsb.wordpress.com/sqlclrwcf/ You can remove the offending line from the machine.config file, or disable the debugging of WCF on the machine with vsdiag_regwcf.exe -u. You will have to recycle SQL once you make the .config file change so that it rejits the app domains.

Related

Akka.Net Persistence with MongoDB

I'm trying to implement Akka Persistence using Mongodb and I am getting an error that says
"Method 'DeleteAsync' in type
'Akka.Persistence.MongoDb.Snapshot.MongoDbSnapshotStore' from assembly
'Akka.Persistence.MongoDb, Version=1.0.4.1, Culture=neutral,
PublicKeyToken=null' does not have an implementation"
Here is my configuration:
var config = ConfigurationFactory.ParseString(#"
akka {
persistence {
publish-plugin-commands = on
snapshot-store {
plugin = ""akka.persistence.snapshot-store.mongodb""
mongodb {
class = ""Akka.Persistence.MongoDb.Snapshot.MongoDbSnapshotStore, Akka.Persistence.MongoDb""
connection-string = ""mongodb://user:pass#paulo.mongohq.com:10083/DbName""
collection = ""AkkaSnapshotStore""
}
}
journal {
plugin = ""akka.persistence.journal.mongodb""
mongodb {
class = ""Akka.Persistence.MongoDb.Journal.MongoDbJournal, Akka.Persistence.MongoDb""
connection-string = ""mongodb://user:pass#paulo.mongohq.com:10083/DbName""
collection = ""AkkaEventJournal""
}
}
}
}");
I think i have created an actor system correctly:
https://gist.github.com/amarwadi/a887b26e14b0d42191b7
and am sending a message to a Persistent Actor and I keep getting the following message infinitely
[ERROR][1/2/2016 2:36:36 AM][Thread 0011][akka://example123/user/section-actor] Method 'DeleteAsync' in type 'Akka.Persistence.MongoDb.Snapshot.MongoDbSnapshotStore' from assembly 'Akka.Persistence.MongoDb, Version=1.0.4.1, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Cause: System.TypeLoadException: Method 'DeleteAsync' in type 'Akka.Persistence.MongoDb.Snapshot.MongoDbSnapshotStore' from assembly 'Akka.Persistence.MongoDb, Version=1.0.4.1, Culture=neutral, PublicKeyToken=null' does not have an implementation.
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at Akka.Persistence.PersistenceExtension.CreatePlugin(String configPath, Func2 dispatcherSelector) at Akka.Persistence.PersistenceExtension.<>c__DisplayClass13_0.<SnapshotStoreFor>b__0() at System.Lazy1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Lazy`1.get_Value()
at Akka.Persistence.PersistenceExtension.SnapshotStoreFor(String snapshotPluginId)
at Akka.Persistence.Eventsourced.get_SnapshotStore()
at Akka.Persistence.Eventsourced.LoadSnapshot(String persistenceId, SnapshotSelectionCriteria criteria, Int64 toSequenceNr)
at Akka.Persistence.Eventsourced.b__76_0(Receive receive, Object message)
at Akka.Persistence.Eventsourced.AroundReceive(Receive receive, Object message)
at Akka.Actor.ActorCell.ReceiveMessage(Object message)
at Akka.Actor.ActorCell.Invoke(Envelope envelope)
Per an update from the developers of Akka.NET Persistence on MongoDB, this was broken in persistence in mongo with the introduction of 1.0.5. It will be corrected shortly.
https://github.com/akkadotnet/Akka.Persistence.MongoDB/issues/12

Ninject not proving params to my Controller, after doing mass update with NuGet

I have an MVC4 project in which I use Ninject. I just use the Ninject MVC3-provided NinjectWebCommon.cs file, in the App_Start folder. I just performed a mass dependency update, with NuGet, without realizing how much trouble it might cause. It broke my Ninject setup, somehow. Prior to running the NuGet update, Ninject would properly create my controllers and provide them with the required constructor params. Now, after the update, I get the following error:
[MissingMethodException: No parameterless constructor defined for this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +113
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
System.Activator.CreateInstance(Type type) +6
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +110
[InvalidOperationException: An error occurred when trying to create a controller of type 'Portal.Web.Controllers.MatterController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +247
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +438
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +226
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +326
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +157
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +88
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +50
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
The code inside of the NinjectWebCommon.cs file is being executed still, though. I can place breakpoints on it, and watch it apply my bindings. I don't think MVC is using it when creating controllers anymore, though.
Does anybody have any idea what might have been broken by this NuGet update?

Spring.Net Placeholder exception

I have the weirdest problem with Spring.net, when trying to convert my project from .NET 3.5 to .NET 4.
Let me summarise our architecture:
Project A (not under my control) has a Sprint.Net config referencing a setting (configurationProvider.url) like this:
<constructor-arg name="Url" value="${configurationProvider.url}" />
Project B (my project, under my control) has another config file with the value of this setting:
<configuration>
<Environment>
<add key="Dashboard.Environment" value="UAT" />
<add key="configurationProvider.url" value="http://something/ConfigurationProvider.asmx"/>
<add key="pkicheck.url" value="http://something/webservices/pkicheck.asmx"/>
<add key="sso.url" value="http://something/webservices/ssoclient.asmx"/>
</Environment>
</configuration>
It all works very well when Project B was .NET 3.5.
When converting this project to .NET 4 (and that's the only change), the whole thing starts failing, and it's giving me this exception:
Could not resolve placeholder 'configurationProvider.url'
It is obviously not finding the configuration setting on the ProjectB configuration file, although this file is there and contains the value.
What could have changed between 3.5 and 4?
Full exception:
<ConfigurationErrorsException d1p1:type="ConfigurationErrorsException">
<ClassName>System.Configuration.ConfigurationErrorsException</ClassName>
<Message>Error creating context 'spring.root': Error registering object with name 'configurationProvider' defined in 'assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111' : Could not resolve placeholder 'configurationProvider.url'.</Message>
<Data d1p1:type="IDictionary"/>
<InnerException d1p1:type="Exception">
<ClassName>Spring.Objects.Factory.ObjectDefinitionStoreException</ClassName>
<Message>Error registering object with name 'configurationProvider' defined in 'assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111' : Could not resolve placeholder 'configurationProvider.url'.</Message>
<Data d1p1:type="IDictionary"/>
<InnerException d1p1:type="Exception"/>
<HelpURL/>
<StackTraceString> at Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer.ProcessProperties(IConfigurableListableObjectFactory factory, NameValueCollection props) at Spring.Objects.Factory.Config.PropertyResourceConfigurer.PostProcessObjectFactory(IConfigurableListableObjectFactory factory) at Spring.Context.Support.AbstractApplicationContext.ProcessObjectFactoryPostProcessors(IList objectFactoryPostProcessors) at Spring.Context.Support.AbstractApplicationContext.InvokeObjectFactoryPostProcessors() at Spring.Context.Support.AbstractApplicationContext.Refresh() at Spring.Context.Support.XmlApplicationContext..ctor(Boolean refresh, String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations) at Spring.Context.Support.XmlApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations) at _dynamic_Spring.Context.Support.XmlApplicationContext..ctor(Object[] ) at Spring.Reflection.Dynamic.SafeConstructor.Invoke(Object[] arguments) at Spring.Context.Support.ContextHandler.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) at Spring.Context.Support.ContextHandler.ContextInstantiator.InstantiateContext() at Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) at Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section)</StackTraceString>
<RemoteStackTraceString/>
<RemoteStackIndex>0</RemoteStackIndex>
<ExceptionMethod>8 ProcessProperties Spring.Core, Version=1.3.0.20349, Culture=neutral, PublicKeyToken=65e474d141e25e07 Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer Void ProcessProperties(Spring.Objects.Factory.Config.IConfigurableListableObjectFactory, System.Collections.Specialized.NameValueCollection)</ExceptionMethod>
<HResult>-2146232832</HResult>
<Source>Spring.Core</Source>
<WatsonBuckets d1p1:type="System.Byte"d1p1:includeArrayAttribute="true"/>
<_resourceDescription>assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111</_resourceDescription>
<_objectName>configurationProvider</_objectName>
</InnerException>
<HelpURL/>
<StackTraceString> at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at Spring.Util.ConfigurationUtils.GetSection(String sectionName) at Spring.Context.Support.ContextRegistry.InitializeContextIfNeeded() at Spring.Context.Support.ContextRegistry.GetContext() at ProjectA.Core.Controller.Initialise(String flavour) in d:\TeamCity8100\buildAgent\work\850180d7b576030f\Code\Src\ProjectA\Framework\Core\Controller.cs:line 238</StackTraceString>
<RemoteStackTraceString/>
<RemoteStackIndex>0</RemoteStackIndex>
<ExceptionMethod>8 EvaluateOne System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a System.Configuration.BaseConfigurationRecord System.Object EvaluateOne(System.String[], System.Configuration.SectionInput, Boolean, System.Configuration.FactoryRecord, System.Configuration.SectionRecord, System.Object)</ExceptionMethod>
<HResult>-2146232062</HResult>
<Source>System.Configuration</Source>
<WatsonBuckets d1p1:type="System.Byte"d1p1:includeArrayAttribute="true"/>
<filename d1p1:type="Object"/>
<line>0</line>
<firstFilename d1p1:type="Object"/>
<firstLine>0</firstLine>
<count>0</count>
</ConfigurationErrorsException>
I eventually found the problem.
We use PropertyPlaceholderConfigurer in our config, and we never set an "Order" property. So Spring was "ordering" on Order, but since Order was always equal to int.Max, the order output was non-deterministic.
Adding Order to the config file fixed it.

CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created

I'm trying to run an Excel 2007 VSTO 3.0 addin we've created. However since installing the ION Trading MarketView Excel Plug-in our add-in no longer seems to load properly and fails with the following error:
Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created. ---> System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
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.CreateInstanceAndUnwrap(String assemblyName, String typeName)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.LoadMafPipeline(AppDomain newDomain, IntPtr hostServiceProvider, AddInInformation info, EntryPoints requestedEntryPoints, OfficeApp officeApplication, OfficeVersion officeVersion, IntPtr& executor)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.CreateCustomizationDomainInternal(String solutionLocation, String manifestName, String documentName, Boolean showUIDuringDeployment, IntPtr hostServiceProvider, IntPtr& executor)
--- End of inner exception stack trace ---
Does anyone have any idea what could be causing this? Any pointers for how I could investigate further?
Thanks,
Tom
Here are some tips you may find on web, in order to fix the problem:
Reinstall VSTOR
Disable other add-ins
Install framework 3.5 sp1
Fix error in the security configuration on the computer that is running the Visual Studio Tools for Office solution
Modify/Disable custom rule of a company's virus software, blocking the .net framework ability to create the 'shadow copy' version of the vsto .dll.
Turn on .NET programmability support http://sqlblog.com/blogs/davide_mauri/archive/2010/07/30/powerpivot-not-visibile-in-excel.aspx
Move the entire solution to .NET 4.0

Problem with conversion of existing project to Silverlight 4

We have a working Silverlight 3 project. After changing the target framework to Silverlight 4 the application won't start anymore. It throws an exception in the following line in the generated InitializeComponent() method:
System.Windows.Application.LoadComponent(this, new System.Uri("/SLAppMain;component/App.xaml", System.UriKind.Relative));
Here is the exception (note the inner exception):
System.Windows.Markup.XamlParseException occurred
Message= [Line: 0 Position: 0]
LineNumber=0
LinePosition=0
StackTrace:
bei System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
InnerException: System.TypeLoadException
Message=Der Typ 'System.Security.AllowPartiallyTrustedCallersAttribute' konnte nicht aus der mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e -Assembly geladen werden.
StackTrace:
bei System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
bei System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
bei System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
bei System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
bei System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
bei System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
bei MS.Internal.XamlSchemaContext.ProcessXmlnsDefinitions(Assembly assembly, String assemblyName)
bei MS.Internal.XamlSchemaContext.EnsureManagedAssemblyAttributesLoaded()
InnerException:
The problem is that the type System.Security.AllowPartiallyTrustedCallersAttribute is not contained in the Silverlight version of mscorlib.dll.
I have no idea how to fix this nor where to look for causes. Has anyone encountered this problem? What could possibly cause this error?
the AllowPartiallyTrustedCallersAttribute class does not exist in SL 4 (neither in mscorlib, nor anywhere else) and did not exist in SL 3 either.
So there must be more than just the conversion from SL 3 to SL 4 to this I guess - is AllowPartiallyTrustedCallersAttribute used in your code somewhere?
Cheers, Alex
EDIT: Actually, you might want to take a look into your app's AssemblyInfo.cs (in the Properties folder). Perhaps the attribute is used there like
[assembly: AllowPartiallyTrustedCallers(true)]
. You could then simply remove it and see what happens...
Do you use Unity for silverlight in your project ? I had exactly the same problem yesterday, and the error disappeared when I de-referenced unity
This walk through REALLY helped me with the same issue http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=5122
Doing a clean build followed by a full rebuild fixed this issue for me.
Dependencies with the same name will be quietly overwritten and packaged into a XAP after the compilation, so make sure that different target platforms of your projects don't build into the same output folder.