An Assembly Needs 2 Copies Of A VB6 Com Dll To Work With.
Feb 15, 2008
Hey guys,
I'm using CLR integration on SQL Server 2005 to call functions from a COM dll made with VB6. I do this to keep some important parts in packed unmanaged code, to make reverse engineering harder.
I keep the COM dll in the system directory. When it's referenced from a .net project, VS copies and uses it as 'interop.myCOM.dll'. When I add the assembly to SQL Server, it needs the referenced 'interop.myCOM.dll' file added. When a class from the COM dll is called by a CLR stored procedure, it needs to locate the real COM dll.
So, the same dll has to be in two different places in two different forms, one as an assembly (interop), and one in its own place. I guess the 'interop' one is not really used, but it just helps to retrieve class information during design time and initialization or something. Everything works ok, but thinking about the packing step and others, this makes things messy. How can I prevent using two copies of my COM dll?
I load the COM class as follows:
Code Snippet
Private Shared ReadOnly m_myClass As myCOM.clsGeneric = New myCOM.clsGeneric
then map stored procedures (shared functions) to related functions of the m_myClass object.
View 1 Replies
ADVERTISEMENT
Aug 2, 2006
Hi
I am a bit paranoid about what I just did to my SQL Server 2005 with this CLR experiment.
I created a Class Lib in C# called inLineLib that has a class Queue which represents an object with an ID field.
in another separate namespace called inLineCLRsql, I created a class called test which will hold the function to be accessed from DB, I referenced and created an instances of the Queue class, and retrieve it's ID in a function called PrintMessage.
namespace inlineCLRsql{
public static class test{
public static void PrintMessage(){
inLineLib.Queue q = new inLineLib.Queue();
int i = q.queueId ;
Microsoft.SqlServer.Server.SqlContext.Pipe.Send(i.ToString());
}
}
}
to access this from the db, I attempted to create an assembley referencing inLineCLRsql.dll. This didn't work as it complained about inLineLib assembly not existing in the db. I then attempted to create an assembley for inLineLib but it barfed saying System.Management assembly not created.
so what I did is (and this is where I need to know if I just ruined sql server or not):
1- ALTER DATABASE myDB SET TRUSTWORTHY ON;.
2- CREATE ASSEMBLY SystemManagement
FROM 'C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Management.dll'
WITH PERMISSION_SET = UNSAFE
3- CREATE ASSEMBLY inLineLibMaster
FROM 'D:inLineServerinLineLibinDebuginLineLib.dll'
WITH PERMISSION_SET = unsafe
4- and finally
CREATE ASSEMBLY inLineLib
FROM 'D:inLineServerCLRSQLinlineCLRsqlinDebuginlineCLRsql.dll'
WITH PERMISSION_SET = SAFE
Everything works after those steps (which took some trial and error). I can create a sproc like:
CREATE PROC sp_test AS
EXTERNAL NAME inLineLib.[inlineCLRsql.test].PrintMessage
and it returns the Queue ID
Is there anything unadvisable about the steps above?
Thanks for your help
M
View 1 Replies
View Related
Jun 21, 2006
When the CLR function executes "CREATE ASSEMBLY" the following error is thrown.
"Could not impersonate the client during assembly file operation."
The CLR function is invoked from Service Broker internal activation stored procedure.
"SELECT user_name()" returns dbo just before CREATE ASSEMBLY execution.
SqlContext.WindowsIdentity.Name is "NT AUTHORITYSYSTEM" as the Data Engine runs with the LocalSystem account.
How do I create a the necessary security context for "CREATE ASSEMBLY" to succeed ?
Service Broker Queue activation with EXECUTE AS = "SELF", "OWNER", domain account or dbo, all result in the above error. The Service Broker assembly having the internal activation stored procedure is registered "unsafe".
View 3 Replies
View Related
May 13, 2004
Hi there!
I was trying to dynamically load a custom WebControl and display it into my WebFrom.
WebControl is loaded by:
System.Reflection.Assembly assembly = System.Reflection.Assembly.Load("myAssemblyName");
Control module = (Control)Activator.CreateInstance( assembly.GetType("myClassName") );
ModulePlaceHolder.Controls.Add(module);
This is working fine. Assembly is loaded and WebControl is created.
But as my Custom WebControl tries to access SQL Server database, i get a "Must declare the variable '@id'" while executing an ExecuteScalar() from a SqlCommand.
Code in my WebControl was perferctly functioning before converting it from a UserControl (.ascx) to Custom WebControl. Parameter '@id' is correctly declared in my query. If i don't use SqlParameters, everithing works fine...
Any ideas??
Thank you so much!!!
Bye!
View 2 Replies
View Related
Feb 22, 2008
I work with February CTP of SqlServer 2008.
I have an Assembly with several UDTs inside. Version of assembly is 1.0.*
I use CREATE ASSEMBLY statement to register this assembly, and it runs without any errors. Then I rebuild CLR solution without doing any changes in source code. In that case the only difference between new and old assemblies is version (difference in fourth part of version).
Then I try to update assembly in SqlServer. I use
ALTER ASSEMBLY <name>
FROM <path>
WITH PERMISSION_SET = UNSAFE, UNCHECKED DATA
statement for this. Statement runs with error:
Msg 6509An error occurred while gathering metadata from assembly €˜<Assembly name>€™ with HRESULT 0x1.
I found the list of condition for ALTER ASSEMBLY in MSDN:
ALTER ASSEMBLY statement cannot be used to change the following:
· The signatures of CLR functions, aggregate functions, stored procedures, and triggers in an instance of SQL Server that reference the assembly. ALTER ASSEMBLY fails when SQL Server cannot rebind .NET Framework database objects in SQL Server with the new version of the assembly.
· The signatures of methods in the assembly that are called from other assemblies.
· The list of assemblies that depend on the assembly, as referenced in the DependentList property of the assembly.
· The indexability of a method, unless there are no indexes or persisted computed columns depending on that method, either directly or indirectly.
· The FillRow method name attribute for CLR table-valued functions.
· The Accumulate and Terminate method signature for user-defined aggregates.
· System assemblies.
· Assembly ownership. Use ALTER AUTHORIZATION (Transact-SQL) instead.
Additionally, for assemblies that implement user-defined types, ALTER ASSEMBLY can be used for making only the following changes:
· Modifying public methods of the user-defined type class, as long as signatures or attributes are not changed.
· Adding new public methods.
· Modifying private methods in any way.
But I haven€™t done any changes in source code, so new version of assembly satisfies all this conditions.
What could be the reason for such behavior?
P.S. I€™ve got the same error, if I add or change any method in assembly before rebuilding.
View 9 Replies
View Related
Feb 29, 2008
I am trying to get a function I created in VB 5 for Access and Excel to work in SQL 2005. I was able to update the old VB code to work in VB 2005. I compiled and made a .dll, and I was able to register the new Assembly in SQL Server. When I try to create the Function, I get an error:
CREATE FUNCTION dbo.Temperature(@FluidName char, @InpCode Char, @Units Char, @Prop1 varchar, @Prop2 varChar)
RETURNS VarChar
AS EXTERNAL NAME FluidProps.[FluidProps.FluidProperties.Fluids].Temperature
Error returned:
Msg 6573, Level 16, State 1, Procedure Temperature, Line 21
Method, property or field 'Temperature' of class 'FluidProps.FluidProperties.Fluids' in assembly 'FluidProps' is not static.
Here is the code (part of it) in the VB class:
Header:
Imports Microsoft.SqlServer.Server
Imports System.Data.SqlClient
Imports System.Runtime.InteropServices
Imports System.Security
Imports System.Security.Permissions
Namespace FluidProperties
'Option Strict Off
'Option Explicit On
Public Partial Class Fluids
Function:
Function Temperature(ByRef FluidName As Object, ByRef InpCode As Object, ByRef Units As Object, ByRef Prop1 As Object, Optional ByRef Prop2 As Object = Nothing) As Object
Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2)
Temperature = ConvertUnits("-T", Units, T, 0)
End Function
If I change the Function Temperature to Static, I get an error that functions cannot be Static. Its been a long time since I created the code and am having a hard time in my older age of getting the cobwebs out to make it work.
I have no problem getting the function to work if I call it from a VB form....so what do I need to do to get it to work on data in my SQL server?
Thanks
Buck
View 20 Replies
View Related
Jan 12, 2006
I previously had an ASP.NET 1.1 site running on my IIS 6.0 server (not the default website) with Reporting Services running in a subdirectory of that website. I recently upgraded to ASP.NET 2.0 for my website and was greeted with an error when trying to view a report. The error was very non-descript, but when I checked the server logs, it recorded the details as "It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process."
First of all, I could not figure out where and how to do this. Secondly, I decided to try to also change the Reporting Services folders to run ASP.NET 2.0 and when I did, I was greeted with the following message when attempting to view a report:
"Failed to load expression host assembly. Details: StrongName cannot have an empty string for the assembly name."
Please help.
View 7 Replies
View Related
May 1, 2008
We have written a test CRL stored procedure to test replacing one of our complex stored procedures but can€™t get it deployed to our SQL server that hosts a mirrored configuration of our production database (very locked down). It works fine on our development instances (not very locked down). It only references the default assemblies that were added when we created the project. All it does is use Context Connection=true to get data, loops though some records and returns the data using SQLContext. CLR is enabled on SQL server, the assembly is strongly signed, and we tried deploy using the binary string with the SAFE setting.
CREATE ASSEMBLY for assembly 'SQLCLRTest2' failed because assembly 'SQLCLRTest2' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message
[ : SQLCLRTest2.StoredProcedures::GetLift][mdToken=0x600001e] Type load failed.
[token 0x02000008] Type load failed.
View 8 Replies
View Related
Oct 5, 2006
I have 2 copies of the SP i work with. An original one and a backup. I usually work with the backup. Is there any way to update the original after updating the backup?. I usually forget what I have changed in the end of the day.
View 1 Replies
View Related
Mar 9, 2006
Hi,
I'm trying to copy results from a view on one table to another table in a different db using DTS in SQL Server Management Studio
Both source and destination db's are version 8.0.194
Everything reports as working, but when I check the results, only one row has copied - DTS reports that 1167 rows were copied.
This happens to different sources and destinations so I doubt it's my query.
When I perfrom the same DTS task using the old enterprise manager DTS in SQL Server 2000, everything copies fine.
Obviously one answer is "Use SQL Server 2000 Enterprise Manager then. " but I'd rather upgrade to 2005 and Management Studio permanently.
Any ideas?
View 1 Replies
View Related
Jan 31, 2008
Hi,
at work all the databases i use are only accessible via the local network, i am wanting to take a copy of the databases and save them as a database file so i can burn them onto cd and take home with me so i can get some extra work done on the weekend (i'd also like to start doing this so i have backed up copies of the database incase anything happens to it)
i was wondering how i can do this? are there any tutorials on the web that someone can point me to? i have SQL Server 2005 Management Studio Express.
TIA
View 1 Replies
View Related
Jan 13, 2006
I'm getting 3 copies of the result set expected, could someone take a look and tell me why. I know I covered this in school, but I can't remember the issue. Thanks
SELECT P.Quantity as Qty,
P.ItemID,
P.VendorCode,
P.Descr as Description,
P.UnitPrice as Price,
P.Amount,
I.Freight,
Rcvd = 0,
I.QtyRcvd as Ship
FROM PurchaseOrderItems P, ReceivedItems I, Received R
WHERE P.POID = R.POID AND R.IntRcdID = I.PRID AND P.POID = 193
View 2 Replies
View Related
Feb 6, 2008
I work for a Geographic Information Systems contractor and we are new to SQL 2005. One of our clients sent us a copy of an .mdf file. I have tried to attach the file but they did not send us the associated log file. What is the most efficient way for us to exchange copies of SQL 2005 databases with clients. Most of our clients are novices with SQL 2005 also.
Thanks,
Jeff
View 2 Replies
View Related
Mar 27, 2008
In previous threads I saw that in a scenario where Log Shipping is active any other Log Backup activities should be avoided in order to let the Log Chain stay intanct.
Until now we just used Mirroring and Full Backup and Log Backup. Introducing Log Shipping to a third Server in a separate location would mean that the existing Log Backup Jobs must be removed or Log Shipping will not work.
I am glad to have read these threads before falling into that trap myself.
A question was raised by my colleague who is responsible for the System and Network Administration. Are these Log Backups that will be performed by Log Shipping just differential? He would not like to see that Log Shipping is pushing or pulling Log's that grow during time.
I named to him two reasons that it must be differential. A Log Backup truncates the existing Log which implies that the next Log is just the difference since the last Backup. Also, it must be differential because the Transations can only be committed once anyway, so Log Shipping implies that those Log Backups are just as big as the incoming Transactions since the last Log Backup.
Did I get this right?
View 3 Replies
View Related
Oct 9, 2007
is it ok to run VSS (shadow copies) on an SQL server?
I have IIS and SQL on the same server. I would like to make shadow copies of my IIS files, but don't want to do anything that could corrupt my SQL databases.
Thanks,
-Bob
View 3 Replies
View Related
May 31, 2007
I am trying to deploy a Database Project with Visual Studio 2005 and SQL Server 2005 Standard.
I import €œSystem.IO€? and have therefore set the permission levels to EXTERNAL_ACCESS.
I am receiving the same error message that many folks have received.
CREATE ASSEMBLY for assembly 'Images' failed because assembly 'Images' is not authorized for PERMISSION_SET = EXTERNAL_ACCESS.
The assembly is authorized when either of the following is true: the database owner (DBO) has EXTERNAL ACCESS ASSEMBLY permission and the database has the TRUSTWORTHY database property on; or the assembly is signed with a certificate or an asymmetric key that has a corresponding login with EXTERNAL ACCESS ASSEMBLY permission. If you have restored or attached this database, make sure the database owner is mapped to the correct login on this server. If not, use sp_changedbowner to fix the problem. Images.
My CLR access is €œon€?
I have tried
1) From master run: GRANT EXTERNAL ACCESS ASSEMBLY to [BuiltinAdministrators].
2) From master run: GRANT EXTERNAL ACCESS ASSEMBLY to €œMy Windows Authentication ID€?.
3) Run ALTER DATABASE MYDATABASE SET TRUSTWORTHY ON
4) In Visual Studio .NET 2005 Set the permission levels to €˜external€™
5) Tried BuiltinAdministrators and my SQL Server Windows Authenticated Login ID for the ASSEMBLY OWNER.
I can compile BUT NOT DEPLOY
Any help would be greatly appreciated.
Regards Steve
View 8 Replies
View Related
Mar 8, 2006
I was trying to understand how VS.NET2005 was deploying .NET CLR assemblies to SQL2005 so I ran a trace and found some interesting results.
VS.NET creates some SQL that looks pretty interesting:
CREATE ASSEMBLY [AssemblyNameHere]
FROM 0x4D5A90000300000004000000FFFF000......<continue binary data>
WITH PERMISSION_SET = EXTERNAL_ACCESS
Boy howdy!
I have tried to reproduce this and create my own deployment application but I cant figure out how they create this binary stream. The info in BOL is not much help and I have not found any samples anywhere on how to create this stream in c#.
Anyone out there been able to get this to work?
-Ben
View 4 Replies
View Related
Nov 25, 2007
I'm working in a team, and need to share a database between the group - we don't have the luxury of sharing a server and connecting to it.
So What we'd like to do is make a copy of the database schema, and then share that through our repository.
I figured I just need to copy the .mdf file from the sql server database folder, and put it in the visual studio directory to work on it?
So I've tried this, but when I try to create a TableAdapter to the database through visual studio, It gives me an "access denied". I figure this is probably something to do with security settings?
Do you think I'll need to change my Database connection from windows authentication to sql authentication?
I don't really know exactly how to do what I'm trying to do, so any help will be appreciated.
View 1 Replies
View Related
Oct 26, 2006
ok her is my question.
there are two developers in different offices and they have started with the same db and keep modifying the stored procedures. in a point they want to update their copies of the DB with each other. Is there a easy way to do this in MS Sql server 2005.
View 1 Replies
View Related
Oct 26, 2006
ok her is my question.
there are two developers in different offices and they have started with the same db and keep modifying the stored procedures. in a point they want to update their copies of the DB with each other. Is there a easy way to do this in MS Sql server 2005.
View 1 Replies
View Related
Mar 21, 2015
I am creating a program that will take a master database and create separate databases for class room training.creating my own app to do this since it will have other stuff to do.i will have a master database that i will need to create multiple copies of. 2-20 copies, it is about 7GB large. it is used in a classroom training course for our company software. it will also copy a folder on the server onto multiple subfolders.each computer in the classroom will access its own copy of the database/windows folders.
What i am looking for is a fast/reliable way to create the multiple database copies. then when the training class is over and a new one is getting started, we will run my program to reset everything back to start.Should i detach/copy/attach or create a master backup and restore it 20 times. What kind of user access pitfalls will i need to look out for.
View 5 Replies
View Related
Jan 14, 2008
Wondering how this is handled by Multicast component. If multiple copies are created in the memory and the size of the dataset is large, this could cause some performance problems. Any thoughts? TIA
View 8 Replies
View Related
Sep 23, 2007
I want to write a batch file that will do just that. The problem is bcp or bulkcopy never works with my code, it doesn't recognize it. Maybe I'm going the wrong way to do this, but I could use some help. Ideally I'll make the batch to do the importing via bulkcopy or something like it of a text file into a table and use windows scheduler to automate it. Be as specific as you can please, I'm very new to sql server.
View 6 Replies
View Related
Dec 31, 2006
Hi,
I am new to reporting services and I'm really stuck on a design problem. Can someone please help me?
I would like to design my own print function. When a user clicks on the print icon (preferably the one that came with reporting services), the report is automatically printed twice, once with "For Person A" and the second time with "For Person B" on it. It doesn't matter where these two labels are placed on the page. These two reports need to be printed on letter-size paper regardless of user's selection. How do I do this with minimum amount of code?
Any help would be greatly appreciated!
View 8 Replies
View Related
Mar 7, 2007
Hi there.
I have an assembly, call it A1, that I've deployed to a SQL Server 2005 database. I can use the managed stored procedures from A1 in SQL Server no problem.
In A1 there is a bit of code which uses the Assembly.Load() method, so load another assembly and use instances of class found in that external assembly. However, when I run the managed stored proc in A1 that uses Assembly.Load() I get the error:
Could not load file or assembly 'A1, Version=1.0.0.0, Culture=neutral,PublicKeyToken='????' or one of its dependencies. The system cannot find the file specified.
(note: for security I've changed some of the above line).
So I changed the Assembly.Load() to use
System.Data,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089
I re-built the project, re-deployed it and ran the code in SQL Server - it worked. I could create an instance of a System.Data.DataSet for example. So why can't I load my own custom assembly? My assembly does have a strong name and it's installed in the GAC. I wrote a console app to try and Assembly.Load() my custom assembly and that worked fine (it was also running on the same server as the SQL Server).
So it's defiantely the SQL Server that can't 'see' my customer assembly. What do I need to do this assembly so that SQL Server will allow me to Assembly.Load it, just as it can with System.Data?
Thanks
Jas.
View 1 Replies
View Related
Sep 13, 2006
Hi,
I have one ClassLibrary three member functions.I have the dll for this...Can some one please tell me how to create a Assembly in .NET.
I need to create a simple private assembly with the dll that i have.
Thanks
View 4 Replies
View Related
Jan 12, 2007
I want use Microsoft.Office.Interop.Excel to access excel file my clr. But that assembly is installed in GAC. How could I register it in SQL 2005?
thanks!
View 5 Replies
View Related
Nov 2, 2006
Good day to ALL,
I have already setup a db to my client.
My sp's are all created using CLR.
If my sp's are changed, how do I deploy them back to my client?
I usually send them a backup of the DB during the first few implementation.
But currently, their DB now contains live data, so I can't just let them restore the backup.
Is there another way?
Thanks and more power!
Arthur
View 1 Replies
View Related
May 30, 2007
I'm using SQL Server Management Studio Express and am unable to create an assembly. The following code:
create assembly HelloWorld from 'c:HelloWorld.dll'
with permission_set = safe
returns the following error:
Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'assembly'.
I noticed that the word "assembly" isn't in blue text and what's more, if I expand the programmability node on any database, there is no assembly node. Anybody know what I'm doing wrong here?
Thanks in advance.
View 3 Replies
View Related
Apr 4, 2007
Is there a way to retrieve the methods within an assembly that are attributed with SqlTrigger or SqlProcedure using T-SQL?
View 1 Replies
View Related
Aug 30, 2012
I'm trying to add an assembly to my SSDT project, and in my assembly, it requires EXTERNAL access, which also means that the assembly has to be signed, and an asymmetric key must be created from the assembly. Â I can't figure out how to get this to work from the SSDT project.
View 8 Replies
View Related
Feb 22, 2008
Hi.
One of my databases has an assembly that uses system.web. Therefore, in the deploy script, the developer has put in a create assembly for it like so
Create Assembly [System.Web]
FROM 'C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Web.dll'
WITH PERMISSION_SET = UNSAFE
followed by the create assembly statements for the actual bespoke assemblies.
The deploy script all works fine, as do the assemblies it creates.
However, when SQL restarts, the calls to the assemblies no longer work, and the only way to get them to is to run the deploy script (which drops them if they exist and recreates them) again.
Not particularly familiar with 2005 & CLR. Is this normal behaviour (I would have expected that once deployed, they were there after re-boot). If it's not how things are supposed to work, what's wrong, and how do I fix it?
Thanks
View 4 Replies
View Related
Sep 26, 2006
Hi everyone, I want to call the .net assembly(DLL) in a DTS package. Can anyone help me as to how to achieve this. I read numerous articles on internet, but couldn't find the one that can help me with this problem.Any help or directing me to an article will be greatly appreciated.Thanks.Vinki
View 9 Replies
View Related