Problems importing a DLL in c# -


i'm having hard times importing c# dll simple test application (console, winform, name it).

basically consist in huge library consumes european community vat checking service (which url believe vat webservice.

the service makes download library, implementation of code you.

what did starting new c# class library in visual studio 2010 , adding this class automatically downloaded webservice own use, , wrote snippet found in web.

using system; using system.collections.generic; using system.linq; using system.text; using system.net; using system.xml; using system.io;   namespace eurovat {     public class eurovat     {         public static array check(string country, string vatnum)         {             bool valid;             string name;             string address;             checkvatservice vatchecker = new checkvatservice();             vatchecker.checkvat(ref country, ref vatnum, out valid, out name, out address);              return new object[] {country,                                  vatnum,                                  valid,                                  name,                                  address                                  };         }     } } 

well, when create new console application, add reference (right click on project name, add reference, browse dll) dll compiled class library project included 2 classes linked/quoted here.

here's code tried use dll:

using eurovat;  namespace dlltest {     class program     {         static void main(string[] args)         {              eurovat test = new eurovat();           }     } } 

basically not able call them program. when try call eurovat object is

error 1 type or namespace name 'eurovat' not found (are missing using directive or assembly reference?)

i tried build, close, reopen project. tried put in winforms , on no avail. error.

what doing wrong? can solve it?

one more question:

what code doing?

    return new object[] {country,                          vatnum,                          valid,                          name,                          address                          }; 

it's returning array of objects? because when run program output thrown out togheter. have cycle throught output sort of loop...

last question, if can help:

i'll have include dll in sql server (2008 think)

i have read subject , discovered passing values sql server c# dll have include various libraries , declare methods sqlprocedures, passing/retrieving values sqltypes (sqlint32, sqlstring, etc etc).

here's came with:

using system; using system.collections.generic; using system.linq; using system.text; using system.net; using system.xml; using system.io; using system.data; using system.data.sqlclient; using system.data.sqltypes; using microsoft.sqlserver.server;  namespace webservicevateuropa {     class program     {         [sqlprocedure]         public static array check(string country, string vatnum)         {             bool valid;             string name;             string address;             checkvatservice vatchecker = new checkvatservice();             vatchecker.checkvat(ref country, ref vatnum, out valid, out name, out address);              return new object[] {country,                                  vatnum,                                  valid,                                  name,                                  address                                  };         }     } } 

i hope it's correct. i'm missing how can cast object sqltypes sqlint32, sqlstring , on. tried got tons of conversion errors , stuff that. won't allow me declare objects ad sqltypes , can't work out last make last return statement output sqltypes.

can show example if possible?

thank all.

  1. your class declared eurovat. whereas initialize object of type eurovat. check register other thing is, try giving namespace , class different names

  2. this: 

    return new object[] {country,                      vatnum,                      valid,                      name,                      address }; 

    creates array of object type, , populates (object)country, (object)vatnum, (object)valid, etc

  3. if right how intend library interact sql server, problem array. sql types, sqlint32, sqlstring, sqlbinary, etc. have implicit conversion operators corresponding types, int, string. since array holds object instances, implicit conversion can not applied. 1 side. on other side, sql server gets result of object[], , cannot handle it. doesn't know how. think should consider using data acess framework handle database, plain ado.net, or entity framework, or whatever. cannot figure out intentions these stored procedures provided.

edit:

try passing result sql server through sqlcontext this:

[sqlprocedure]   public static void userservice(string country, stringvatnum)     {            object[] serverresponse = checkservice(country, vatnum);      // variables.            sqlmetadata column1info;             sqldatarecord record;      // create column metadata.           column1info = new     sqlmetadata("column1", sqldbtype.variant);            // create new record column metadata.            record = new sqldatarecord(new sqlmetadata[]{column1info});       // mark begining of result-set.      sqlcontext.pipe.sendresultsstart(record);       foreach (var o in serverresponse)            {          record.setvalue(0, o);          sqlcontext.pipe.sendresultsrow(record);              }             // mark end of  result-set.              sqlcontext.pipe.sendresultsend();   }  public static object[] checkservice(string country, string vatnum)   {      bool valid;              string name;             string address;              checkvatservice      vatchecker = new checkvatservice();          vatchecker.checkvat(ref country, ref vatnum, out valid, out name, out address);       return new object[] {country,                           vatnum,                           valid,                           name,                           address                          };      } } 

Comments