Link to home
Start Free TrialLog in
Avatar of QPR
QPRFlag 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?
Avatar of nmarun
nmarun
Flag of India image

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
Avatar of QPR

ASKER

The DLL itself is the entire project (windows class library)
Can you please attach a zipped version of the project?
Avatar of 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.
Avatar of 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);
           
         }
    }
    }
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
Avatar of 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.,
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
Avatar of tampnic
tampnic
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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)
Avatar of QPR

ASKER

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