How can i have 'Create Assembly' reference the build output path.
I have an SQL CLR that references a web service.
I have an entry in the PostDeployment script
CREATE ASSEMBLY TestWebServiceClientXML from N'\\TestServer2012\clrdeploy\Test\TestWebServiceClient.XmlSerializers.dll' WITH permission_set = EXTERNAL_ACCESS
Currently this works fine. I build the TestWebServiceClient separately manually, that builds the dll and XMLSerializer dll to a share that SQL can see. When i then publish the database project with the CLR in that references this, the PostDeployment scripts uses the XMLSerializers dll I've just built from the share.
How can I get this scenario to work with a build server? All the build outputs, including the XMLSerializers dll will go to a single build output path on the build server and when the post deployment script runs it will create an assembly from an old version on the share '\TestServer2012\clrdeploy\Test\' as this is hard coded, not the version just built.
Eventually I want this to run within Release Management. Anyone done this before?
Using SQLCMD variables, have the build server pass the build folder's path to SqlPackage.exe as a SQLCMD variable. Then modify your post deployment script to look something like this:
CREATE ASSEMBLY TestWebServiceClientXML from N'$(BuildFolder)\clrdeploy\Test\TestWebServiceClient.XmlSerializers.dll' WITH permission_set = EXTERNAL_ACCESS
Related
I have built software that is capable of exporting DTSX package automatically. This package among other objects has also a ScriptTask (C#). All are compiled and run just fine.
Now the new requirement is to call a class in that ScriptTask, which exists inside an external DLL we have built, so other applications can consume the same code. So we implemented a loading mechanism of the DLL, using reflection.
Assembly clientLib = Assembly.LoadFrom("C:\\......\\mylibrary.dll");
Type licenseCheckType = clientLib.GetType("myclass");
object instance = Activator.CreateInstance(licenseCheckType);
The code is running just fine, but there are several permission issues during deployment.
Running the package from DataTools, the package fails because cannot find the file. If I executed the DataTools as administrator is working. Still, I don't get it, as a user I should be able to browse the file.
Running the package from SQLAgent(this is important), the package fails. If I set the SQL Agent service user with "Local System" or "Administrator" user the is working.
I am looking for a way to find how I can make it work with a simple user by adding permissions to that path if necessary, but still, keep failing. I tried to set a simple domain user as SQLAgent Service account and give Full Control as a start to the directory without success.
Error: Exception has been thrown by the target of an invocation.
Implementing the loading mechanism from GAC, is working, but I would like to explore the other way as the DLL in my case, this DLL is referencing a LiteDb file in the system directory, and it would be nice to have them all together.
Assembly clientLib = Assembly.Loadm("mylibrary");
Type licenseCheckType = clientLib.GetType("myclass");
object instance = Activator.CreateInstance(licenseCheckType);
As a summary:
Using the GAC
UI will reference the local DLL because exist in bin folder
SSIS will reference the GAC DLL because of loading from GAC, which references a db file from local folder
Using the Local (problematic)
UI will reference the local DLL because exist in bin folder
SSIS will reference the local DLL because of loading from local folder, which references a db file from local folder
I have:
SSIS/.dtsx package with a script task in SSIS that I added references to. It works fine locally (assuming the .dlls are in the GAC).
When depolying on the server it failes (assuming the .dlls are NOT references in the GAC) and I can not add them.
The SSIS package is stored in Integration Services on the SQL server in the Stored Packages - MSDB
The job runs on a schedule
I do not have access or the ability to add .dlls or add items to the GAC on the server.
What I need to do is find a way to include the .dll in the script task inside the SSIS package so that the References point to those .dlls instead of any in the GAC.
I searched quite a bit and could not find a way to do this. Is it even possible? If so what/how do I do it?
Locally it does work, in server it cannot find a required reference. what referenced dll is missing? you know it?
Once you know what dll you need, get a copy of it and, even if you cannot install it on the server GAC, you can deploy it in the same folder you deploy your executable.
At runtime, your executable will first try to load the dll from the same folder, if not found, it will try searching in GAC.
Though there are many articles to tell about the Pipeline Component deployment. I dont understand how to do it. I build the solution and I have the .dll file. How do I GAC the Pipeline Component Assembly.
Where do I find the assembly, Is the .dll file is the assembly?I am new to .NET or C# I dont understand any of the terminologies. Can anybody help me with the details.
This is a good way of looking at it (taken from Difference Between Assembly and DLL):
An assembly is .NET's "minimum unit of deployment". Usually an
assembly corresponds to a single file, but it doesn't have to - you
can have multiple files, with one of them being the master which knows
where all the other bits are.
Single-file assemblies are usually DLLs or EXE files. If you've got a
normal class library and you just want to send it to the other side,
the DLL is what you want. I'd only worry about more complicated
scenarios as and when you run into them :)
In your case, the DLL is the assembly.
To deploy your custom pipeline component, you would need to
1) Add it to the Global Assembly Cache (use gacutil4)
Check here for more information: http://msdn.microsoft.com/en-us/library/dkkx7f79(v=vs.100).aspx
2) Copy it the Pipeline Components folder (default in C:\Program Files (x86)\Microsoft BizTalk Server 2010\Pipeline Components)
3) Restart the Host Instance (likely BizTalkServerApplication in your case) and deploy your new pipeline which makes use of the pipeline component.
I'm using Visual Studio 2012 and I wrote some CLR SQL assembly and deployed it on several SQL Servers. I added stored procedure that calls web service to this assembly, and when i tried to re-deploy my assembly, it failed on one of the servers.
I've got an error:
Cannot load dynamically generated serialization assembly. In some hosting environments assembly load functionality is restricted, consider using pre-generated serializer.
I'm creating assembly and stored procedures using script generated by VS (MySolution.MyProject_Create.sql). This script creates assembly:
CREATE ASSEMBLY [AssemblyName]
AUTHORIZATION [dbo]
FROM 0xx4D5A9(....)
WITH PERMISSION_SET = EXTERNAL_ACCESS;
But there is no command for creating XmlSerializers.dll file, so I have to copy this file to remote server, and run command:
CREATE ASSEMBLY [AssemblyName.XmlSerializers] FROM
'C:\path\AssemblyName.XmlSerializers.dll'
WITH PERMISSION_SET = SAFE
And then script XmlSerializers.dll manually to avoid copying this file to other servers.
Is this possible to change some settings so Visual Studio will generate create script for XMLSerializers.dll, too?
Go to project properties, build tab, and set "Generate serialization asssembly" to On.
I'm using Visual Studio's standard setup. During my solution build process, a DLL is modified and re-signed. I want the modified DLL to be copied to a setup that is also in the same solution so that it is installed on the target machine. The DLL should end up in the target machine's GAC.
Is there any way to do this in one build process? The DLL is modified each build.
To deploy an assembly to the target computer GAC with Web Setup project, we can drag the assemblies to Global Assembly Cache Folder(Right-click File System on Target Machine, click Add Special Folder, and then click Global Assembly Cache Folder). For more information, see http://support.microsoft.com/kb/324168
We also can try to run some scripts to register assemblies through the Gacutil Tool (http://support.microsoft.com/kb/315682) on target machine in Custom Action of Setup Project.
For the Custom Action example, see http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx
Make the install do two components using the same file.
One as a global assembly, and one as a private assembly.
These links should be helpful:
http://blogs.msdn.com/b/astebner/archive/2005/06/24/432521.aspx
And
http://msitekkie.wordpress.com/2011/02/03/installing-net-assemblies/
Hope that helps