 |
|
 |
Hi,
I am trying to create a assmbly for System.Web.dll as per the command above:
CREATE ASSEMBLY
[System.Web] from
'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.dll'
with permission_set = UNSAFE
GO
But it results in a error:
Msg 10300, Level 16, State 2, Line 1
Assembly 'System.Web' references assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: version, culture or public key mismatch). Please load the referenced assembly into the current database and retry your request.
Can you please guide me as to how can I go ahead.
Thanks.
|
|
|
|
 |
|
 |
I had the same problem. I'm running on a x64 Vista with x64 SQL Server 2005.
I tried updating to .NET 3.5 SP1 and SQL2005 SP3 but that didn't fix the error.
What worked for me was importing the Web assembly from Framework64 directory.
CREATE ASSEMBLY [System.Web] from
'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Web.dll'
with permission_set = UNSAFE
GO
I also tried importing all of the above assemblies from their x64 directory but that caused the error others complained about:
System.TypeInitializationException: The type initializer for 'CLRTrigger.Triggers' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'System.ServiceModel, 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)
So, I only imported Web with its x64 version. That worked for me.
|
|
|
|
 |
|
|
 |
|
 |
Thanks for the article, it helped greatly by confirming the (large number of) assemblies that must be added to SQL Server to use WCF.
I hope this tidbit might help someone. I ran into this boggling exception, which threw on client construction:
The type 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior, Microsoft.VisualStudio.Diagnostics.ServiceModelSink, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' registered for extension 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior' could not be loaded.
After a significant amount of digging I found removing the following from the machine.config file fixed the problem, which seems to affect Vista machines.
<commonBehaviors>
<endpointBehaviors>
<Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior/>
</endpointBehaviors>
<serviceBehaviors>
<Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior/>
</serviceBehaviors>
</commonBehaviors>
|
|
|
|
 |
|
|
 |
|
 |
Hi,
I get the error below when I try to change a field in the table to
activate the trigger.
Have googled around for this problem and cant find a solution or fix.
My System consist of following:
Vista Ultimate x64, Visual Studio 2008 Pro RTM SP1.
cheers,
Raianeh
---------------------------
Microsoft SQL Server Management Studio
---------------------------
No row was updated.
The data in row 17 was not committed.
Error Source: .Net SqlClient Data Provider.
Error Message: A .NET Framework error occurred during execution of user-defined routine or aggregate "WCFTrigger":
System.TypeInitializationException: The type initializer for 'CLRTrigger.Triggers' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'System.ServiceModel, 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)
System.IO.FileLoadException:
at CLRTrigger.Triggers..cctor()
System.TypeInitializationException:
at CLRTrigger.Triggers.CLRTrigger()
.
The statement has been terminated.
Correct the errors and retry or press ESC to cancel the change(s).
---------------------------
OK Help
---------------------------
|
|
|
|
 |
|
 |
Hi,
I think I had this error once during the development of the article. I believe, although it was a while a go that I wrote it, that the problem is occuring because the assembly you reference in the CREATE ASSEMBLY statement (the one for the System.ServiceModel) is a different version from the one that you have installed in the GAC (C:\windows\assmbly).
You should be able to fix the issue by:
1, Check the version of System.ServiceModel in SQL Management studio (yourDB\programmability\Assemblies).
2, Check the version of System.ServiceModel in the GAC (C:\windows\assembly)
3a, If the version the GAC is older, drop the newer version into the GAC so that it matches the one loaded into your db.
4a, If the version in the GAC is newer:
Drop the assembly from your db and then CREATE ASSEMBLY with the newer dll.
Hope this helps.
Sam
|
|
|
|
 |
|
 |
firts i would like to say that is was really a good artical..
now i have a problem, i followed ur example, every thing worked hust fine till i deployed the project - i called it "PlugInServerProject"- I get the following error :
"CREATE ASSEMBLY failed because type 'Triggers' in safe assembly 'PlugInServerProject' has a static field 'endpoint'. Attributes of static fields in safe assemblies must be marked readonly in Visual C#, ReadOnly in Visual Basic, or initonly in Visual C++ and intermediate language"..
any ideas how can i solve that?..
thank you
|
|
|
|
 |
|
 |
I had the same issue. On your PlugInServerProject, go to properties, and go to the Database tab. Now change the permission level from 'safe' to 'unsafe', save, and you should be able to deploy at that point.
|
|
|
|
 |
|
 |
i had the same problem with you, am using Windows 7 and VS2008. When i opent he prokject, its permission level was 0, when i change to unsafe or any other values, the popup just keeps poping saying its not a valid value, then i cant save or even exit VS2008, have to reboot the system always...
|
|
|
|
 |
|
 |
Hi, on my developer machine I've got installed VS2005 and VS 2008.
When creating an Sql Serverproject in Visual Studio 2008 there is no possibility to add a Service,
reference only webreferences are possible. I tryed to rebuild the Sample in Visual Studio 2005
..problem was the installation of the WCF add on.
I had to create an registry entry to emulate the existence of Frame work 3.0
(Installed was 1.1;2.0;3.1;3.5) to be able to install
all in all I could rebuild the project, but when init the static myClient
myClient= new ServiceClient.localhost.ServiceContractClient(httpBinding, endpoint);)
in the CLR-Trigger I get error Message:
The type 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior, Microsoft.VisualStudio.Diagnostics.ServiceModelSink, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' registered for extension 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior' could not be loaded. (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config line 188)
..After small Google search I found a "solution" to remove that line from machine.config
<commonBehaviors>
<endpointBehaviors>
<Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior></Microsoft.VisualStudio.Diagnostics.
ServiceModelSink.Behavior>
</endpointBehaviors>
<serviceBehaviors>
<Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior/>
</serviceBehaviors>
</commonBehaviors>
I removed the two lines with ServiceModelSink and the client was able to init...but now, when calling a method the following error occurs:
Content Type text/xml; charset=utf-8 was not supported by service http://localhost:8000/services/myservice.
The client and service bindings may be mismatched.
Anyone an idea how to get the trigger work?
|
|
|
|
 |
|
 |
Have you got access to a 'clean' machine to try it on, i.e. one with just VS2005?
|
|
|
|
 |
|
 |
Yes, but there's the same Problem with Framework 3.1 installed
|
|
|
|
 |
|
 |
Does my demo run ok from either machine, i.e. do you just get this when trying to recreate the project?
|
|
|
|
 |
|
 |
rebuild means.. i tryed to get your demo running. (PS: maybe Skype or icq faster? skype: antinero icq: 120965230 )
|
|
|
|
 |
|
 |
Sorry, I don't use ICQ or Skype but my msn is: shilessam@hotmail.com
You should be able to add the reference in via the 'Add Web Reference' option in vs 2008. I have just tried this my self and it works.
You will need to modify the host slightly by adding the following few lines of code before the ServiceHost.Open() method call:
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
myHost.Description.Behaviors.Add(smb);
Let me know how you get on with that.
|
|
|
|
 |
|
 |
....in the final result we think there is no posibility with Visual studio 2008. We tried to consume via adding a Webreference, but this didn't work.
The only workaround I see in time is using a webservice hosted in IIS --> adding this via webreference....(don' forget to add the *.xmlserializer file)
Not the finest way, but works.
|
|
|
|
 |
|
 |
I have to correct my last statement. I've found the way to run that example under visual studio 2008. When Creating a new Sqlserver Project you can select the framework version. When select framework version 3.5 the clear project has in its property page selected framework version 2.0 again!!! Just setting framework 3.5 on this property tab allows you to add a Service Reference and run the Trigger assembly marked as unsafe but without any Serializer file.
Don't know if this is a VS bug, but I can't beleave that this was, what microsoft intended to.
|
|
|
|
 |
|
 |
Excellent article...
I had a few issues that I had to resolve...
Firstly, I had an issue with the compatability level of my database
EXEC sp_dbcmptlevel Testdb, 90; - running this script resovled this issue thereafter I had the second issue. The fix below worked for me...
Workaround: (Temporary) disable WCF debugging by invoking this command line utility:
[Program Files]\Microsoft Visual Studio 9.0\Common7\IDE\vsdiag_regwcf.exe -u
Now the WCF client inside SQL Server runs just fine. After you've done you can re-enable WCF debugging services by calling same exe with different parameter:
[Program Files]\Microsoft Visual Studio 9.0\Common7\IDE\vsdiag_regwcf.exe -i
Note that administrator privileges are required to disable/enable it.
http://cs.rthand.com/blogs/blog_with_righthand/archive/2009/01/09/Calling-WCF-services-from-within-Sql-Server.aspx[^]
|
|
|
|
 |
|
 |
Incredible! I thought I would have days of headaches trying to get data from our new service into SQL, the whole thing took just a few hours. Very, very good, thanks a million!
Gert-Jan
|
|
|
|
 |
|
 |
No problem, glad it helped.
|
|
|
|
 |
|
|
 |
|
 |
Thanks very much for that Mark. It makes perfect sense. I was actually discussing this subject with a friend of mine the other day and he mentioned that using a table as queue is the standard practice for this sort of thing.
The asyncronous method is clearing the preferable option but I included the syncrounous method in the sample to keep things as simple as possible.
Thanks very much for the insight.
|
|
|
|
 |
|
 |
Sam Shiles wrote: Thanks very much for the insight.
Happy to help
Sam Shiles wrote: I included the syncrounous method in the sample to keep things as simple as possible.
Just a little friendly advice, it would a good idea to include some disclaimer or warning against using the syncronous method in a production system. I certainly understand simplifying things to make your key point more clear. People are going to shoot themselves in the foot without any help from us. But the more projects I work on as a consultant the more code I see written by people who never looked beyond the simple example they found online (yes, I'm guilty as well). So because of that I see it as my responsibility to try and guide people in the right direction when I can.
Thanks for listening.
|
|
|
|
 |
|
 |
I take your point! Updated accordingly!
|
|
|
|
 |