Avatar of QPR
QPR
Flag for New Zealand asked on

Where to put the dll

I have created a DLL in visual studio 2010 (c# and v3.5)
An app that we have includes an integrated scripting environment that you can use to run functions within the program.
It is simple VB and you can reference a DLL by simply typing
references my.dll
imports my.dll

However I cannot get it to "find" my DLL at runtime.
I have put the DLL in the GAC using gacutil but still nothing.

After throwing it into a few random areas of the app's server folders I got it to see the DLL when checking syntax but at runtime it still says it cannot find my DLL.

Is there a way to know where this app is looking, what path it is checking? I can't ask the vendor because (although they offer the environment) they do not provide support for custom code.

My recent DLL experience has either been in the GAC or in the bin folder of an app.
So a generic question, if putting a DLL outside of the gac, do you still have to reg the dll these days?
ASP.NET.NET ProgrammingWeb Development

Avatar of undefined
Last Comment
QPR

8/22/2022 - Mon
nmarun

No. If you put it in the bin folder you do not have to register it. Also adding it to the GAC if only one app is using it is not recommended.

See if you can add the dll as a reference to your project. All you need to do then is to compile it in Release mode and publish the application. This way it will ensure that all the references will be 'visible' to your application.

Thanks,
Arun
QPR

ASKER
The DLL itself is the entire project (windows class library)
nmarun

Can you please attach a zipped version of the project?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
QPR

ASKER
I'm not sure i understand why, I have a compiled DLL that I need another app to be able to reference via its internal scripting feature.
QPR

ASKER
The project is a simple cs file, a web service reference and a key
I am referencing the dll in the scripted environment add trying to use AddListItems()

My DLL cannot be found at runtime (of the script) apparently.
Here is the contents of the CS file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace PR2Sharepoint
{
    public class SPFunctions
    {
     

         public static void GetListItems(string theTitle) // Get the title field for all items in the sample list
        {
            SPSampleList.Lists client = new SPSampleList.Lists();
            client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
            viewFields.InnerXml = "<FieldRef Name=\"Title\" />";
            try
            {
                XmlNode listItems = client.GetListItems("sample", null, null, viewFields, null, null, null);
                foreach (XmlNode node in listItems)
                    if (node.Name == "rs:data")
                        for (int f = 0; f < node.ChildNodes.Count; f++)
                        {
                            if (node.ChildNodes[f].Name == "z:row")
                            {
                                string title = node.ChildNodes[f].Attributes["ows_Title"].Value;
                                Console.WriteLine(title);
                            }
                        }
                //Console.ReadKey(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.TargetSite);
                Console.ReadKey(false);
            }
        }

        public static void AddListItems(string title)
        {
            SPSampleList.Lists client = new SPSampleList.Lists();
            client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

            XmlDocument doc = new XmlDocument();
            XmlElement batch_element = doc.CreateElement("Batch");
            string item = "<Method ID=\"1\" Cmd=\"New\">" + "<Field Name=\"ID\">New</Field>" + "<Field Name=\"Title\">" + title + "</Field>" + "</Method>";
            batch_element.InnerXml = item;
            client.UpdateListItems("sample", batch_element);
           
         }
    }
    }
nmarun

1. I do not see a 'using' statement mentioning your 'my.dll'. Typically it will look like:
using my;
or
using my.[someNameSpace];

2. Is the SPSampleList.Lists class declared in your my.dll assembly? If not, I don't where in the AddListItems method you are referencing a class from your my.dll assembly.

Once again, please attach your project and I will be better able to help you.

Arun
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
QPR

ASKER
You will not see that anywhere in the dll because the place where I am referencing and importing the dll is within a scripting environment within a 3rd party application.
There is no problem with my dll - my dll works perfectly, I can use it with a console app.

I now need to distribute this compiled dll to a place on the server where this 3rd party application can "see" it.
I have tried the GAC (using gacutil) and the bin directory of the 3rd party application. But the scripting feature of the 3rd party application says cannot find my.dll when I try to execute the script.

This question is all about where I need to gac/regsvr/regasm in order for this app to be able to see it.,
nmarun

What does the 3rd party application owner say about this? Since they are the ones who are providing the 'scripting feature'.

Thanks,
Arun
ASKER CERTIFIED SOLUTION
tampnic

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
QPR

ASKER
Not 100% sure - they provide the environment but not support for custom DLLs.
Their own scripts reference their own DLLs as well as .NET framework DLLs such as system.windows....

So I thought putting it in the GAC would have done the trick. There are many other potential candidates it could go but all so far are prooving fruitless.

Not sure what these are: DLLIMPORT (cdecl) or WINAPI (stdcall)
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
QPR

ASKER
Same directory as the exe.
Thanks! this got it to run fine