Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7499695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:54:39+00:00 2026-05-29T19:54:39+00:00

In order to call a webservice, I’ve created a DLL in C# .NET 2.0

  • 0

In order to call a webservice, I’ve created a DLL in C# .NET 2.0 .

After registering the DLL in SQL Server 2008 R2, I tried, in this DLL, to retreive its directory in order to load a configuration file.

The problem is all methods I found on Google doesn’t work, and it’s a problem because I can’t load the file. I don’t want put some “hard paths” in my code, because it can change depending of the environment.

There is how I register my dll in SQL Server 2008 :

DROP FUNCTION [Tools].[CallWriteDepot]
GO
DROP FUNCTION [Tools].[CallExtractDepot]
GO
drop assembly SqlAssembly
go

create assembly SqlAssembly
from 'C:\webservices\dll\SqlAssembly.dll'
with permission_set = unsafe
go
---------------------------------------------------------------------------------------------------
CREATE FUNCTION [Tools].[CallWriteDepot](@xmlInputFile [nvarchar](max))
RETURNS [nvarchar](max) WITH EXECUTE AS CALLER
AS 
EXTERNAL NAME [SqlAssembly].[SqlAssembly.Main].[writeToSafe]
GO

---------------------------------------------------------------------------------------------------
CREATE FUNCTION [Tools].[CallExtractDepot](@xmlInputFile [nvarchar](max))
RETURNS [nvarchar](max) WITH EXECUTE AS CALLER
AS 
EXTERNAL NAME [SqlAssembly].[SqlAssembly.Main].[readFromSafe]
GO

As you see, the DLL is in C:\webservices\dll\SqlAssembly.dll and it is impossible to find this path in the DLL code, as you can see below.

There is the result after few tests :

Assembly.GetAssembly(typeof(SqlAssembly.Main)).CodeBase
Result : empty
attrTest2.Value = Assembly.GetAssembly(typeof(SqlAssembly.Main)).Location
Result : empty
Assembly.GetCallingAssembly().Location
Result : C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\SqlAccess.dll
Assembly.GetCallingAssembly().GetName().CodeBase
Result : file:///C:/Program Files/Microsoft SQL Server/MSSQL10_50.MSSQLSERVER/MSSQL/Binn/SqlAccess.DLL
Assembly.GetExecutingAssembly().Location
Result : empty
Assembly.GetExecutingAssembly().GetName().CodeBase
Result : empty
Directory.GetCurrentDirectory();
Result : C:\Windows\system32
AppDomain.CurrentDomain.BaseDirectory;
Result : C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\
Environment.CurrentDirectory;
Result : C:\Windows\system32

If anybody knows how SQL Server register a DLL function ? It’s like it save the function in a memory zone and don’t read the dll file anymore.

If anybody have the solution too 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:54:41+00:00Added an answer on May 29, 2026 at 7:54 pm

    When you create an assembly in SQL Server the binary code of the dll is loaded into SQL Server. You can find it in sys.assembly_files. The dll used to create the assembly is not used when you execute functions in the assembly.

    A possible solution to your problem could be to have an .ini file that contains the path to the configuration file. Just make sure you put your .ini file in a place you can find it through the path environment variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed this post http://neurochannels.blogspot.com/2010/05/how-to-run-r-code-in-matlab.html , to install R(D)Com server in order to call
Basically I want to set Content-Type: application/json; in order to call a dot net
I want to call some web-service webmethods on asp.net submit button's click in order
Can I see in firebug profiler funcitons list in order those call? Do you
I'm trying to add a method to the Event prototype. In order to call/set
I have a domain Aggregate, call it Order that contains a List of OrderLines.
In order to make bundle work on its own i would like to call
Do you use the alias method in order to add more ways to call
I m trying to convert the following code to another AJAX call, in order
I have a SQL Server table full of orders that my program needs to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.