views:

209

answers:

3

I am trying to create a set of WCF web services for an existing website that uses web site instead of a web application project. I would like to create a DLL that I drop into the Bin folder instead of writing all my code inside the App_Code directory. Ideally, I want to create a project and reference it from the web site, but I am running into a difficult situation.

The DLL will need to reference configuration and other DLLs located inside the bin folder of the website causing a circular reference. How do I get around this issue?

A: 

Circular references can never be built soley from soure. I'd either collapse the two projects or use reflection to break the circular dependency.

Christopher Painter
+1  A: 

Why is it a circular reference if you are referencing external dlls? You can still have references to configuration without any references to your compiled website's dll. Besides, you will have to get it from Temp ASP .Net files, as websites are compiled on request.

If you really do reference some code from your website, why not put it in your newly made library and reference that code from your website?

HeavyWave
Just to clarify, the service that I am creating will run within the web site folder. It will need access to the current db, user, etc. If I put it inside external project, I will have to painfully recreate the environment, which already exists. I guess my question is how do I get round having to write all my code inside App_Code?
Joel Rodgers
I don't see the problem. You can still use the same config, resources, etc. from an external dll, provided it is inside the same AppDomain as your website.
HeavyWave
Brain fart on my part (BFOMP)! You make total sense now, I was thinking in terms of referencing the entire web site project from the dll project, instead of individual DLLs. I knew about this but I guess the Web Site project made it all conceptually fleeting. It has something to do with the fact that Web Projects don't operate like normal VS projects. Web Projects should be banned and made available by prescription only.
Joel Rodgers
They do actually, VS creates a project automatically and stores it in C:/Users/{Username}/Documents/ or something like that. And if you go to ASP .Net Temporary files you can see your website in compiled form. And of course dlls in your Bin folder can reference each other.
HeavyWave
A: 

Copy the pages that cause circular references into different folder and compile the application. I had solved my problem by this fix.

renjucool