tags:

views:

264

answers:

1

I'm a newbie with WCF. I had wcf service in iis running fine. I made a code change to the DataAccessLibrary.dll in which the main class is DAL. The service.cs file references this dll. I dropped the new dll into the bin folder. Now an error is thrown in the service.cs code that says "DAL does not exist in the current context" I'm thinking this has something to do with the service.cs class referencing the old dll and not the new one. But I'm not sure how to go about fixing it.

+1  A: 

Worse case scenario, if you're service code references the DAL assembly in Visual Studio, is to open the WCF project/solution again, make sure the reference is up to date to the DAL (either by project reference or DLL reference) and rebuild / republish.

There are likely better ways, but this should work as a fallback option...

EDIT:

To provide some feedback on perhaps a more efficient way to work with WCF development - here is how we work on these systems:

  1. External common libraries such as DAL, Core business assemblies, etc. are stored on the network (For example, under a UNC such as \\DEVSTORE\CommonAssemblies\DAL\MyDal.dll, etc.)
  2. In your WCF application in Visual Studio, add an actual reference to the DLLs on the network. The default settings will copy the dll locally to the bin folder during the build
  3. Use the publish feature in Visual Studio to output the svc, bin folder, web.config etc. to either a temporary folder or the IIS app folder itself.
  4. When working on the common DAL or other common libraries in VS, simply ensure when you build, you put a copy of the DLL to the common network location.

Makes for a pretty simple dev experience.

KP
By republish, you mean drop all the necessary files (interface file, service class file, and dll's) into the correct folder in IIS? The webservice project doesn't have any references added to it through the "add reference" option. The interface class and the service class both have a using statement for the DataAccessLibrary.dll though. Looking in the solution explorer, it does have a Bin folder with all of the dlls from other projects in the solution. This project was inherited which is why I don't know much about it.
cyrix86
So the DAL assembly must have been added manually to the bin folder for the WCF project in visual studio then, otherwise it never would have built (with the same error you stated)... If you have the WCF solution in VS, check the bin folder for the DLL, you may need to overwrite it there. What type of code changes did you make (i.e. new functionality, namespace changes, access level changes - private/public, etc.)?
KP
nothing like that, There is a method in the DAL library that queries a DB. All I did was add another "AND" condition to the SQL. I've verified that the code works. I have a windows service that uses the same DAL library and it works with no problem. The problem is that the DAL class name itself is not recoginized when called in the service.cs code. I will try overwriting the dlls in the Bin folder of the wcf project and then rebuild/deploy to IIS. I'll get back to you in a minute
cyrix86
ok I deleted the old dll from the Bin and added the new dll from the DAL project and now "DAL does not exist in the current context" is being thrown as a build error in the service.cs class. I haven't deployed to IIS yet - this is in VS
cyrix86
Ok nvm for some reason DAL class name changed to Dal, so when I changed the service.cs code from DAL.method() to Dal.method() it builds fine
cyrix86
going to try to move to IIS now
cyrix86
Ok that did it! everything is working great. I had to compile the DAL library, add the complile dll manually to the wcf service Bin folder, and then build the wcf project. Then I deleted the service.cs and DAL library from IIS and dropped the new ones in. What a pain! I'm new to WCF so why would the wcf project be set up this way?
cyrix86
For whatever reason, it sounds like your predecessor wanted to keep the DAL library external to the WCF app/project. This is fine, however in that case it would have been better to have a network or drive location where precompiled/shared DLLs are stored. From your WCF app, you add an actual reference to it. Then if you build the DAL library and overwrite the common assembly on the network, you simply rebuild the WCF app and it'll get the latest version of the DAL without manually copying to the bin folder..
KP
In the end though, it sounds like the problem was your casing (Where DAL became Dal). C# is case sensitive so of course your code would break...
KP
The wierd thing is that, originally, in the VS code window, "DAL" was fine - no error. The casing error only manifested itself after I manually overwrote the DAL dll in the wcf project Bin folder
cyrix86
Anyhow, Thank you so much for your help Kevin
cyrix86