problems when make a web service as an alternative to dll - asp.net

Q:
Recently , i face some problems, i have a dll common among a lot of applications,and any change to this dll require to build it, copy and paste it in each bin folder of these applications ,and add the new reference so i decided to convert this dll to a web service in stead to overcome this overload..
I make a web service application contains set of web services(mapping to each class).
I face some problems here:
In the original dll, there are
classes use methods exist in other
classes in the same dll, and i face problems when i
tried to use web service methods in
other web service class.how to fix
this problem.
In the original dll there are set of
static classes with static
methods.how to make the equivalent in
my web service application.
Any overload method cause a problem
in my web service.
When using Dictionary<string, string>
as a parameter in my method.
Note:the original dll contains the connections to the data base. Is converting it to web service is the optimum solution?which one is faster in my case a web service or the dll?Should i tend to WCF instead of?
thanks in advance.

In my applications I usually have all related projects in the same solution. But when I need to use projects across applications I replace the project for a dll reference.
Because I use Subversion I solve the problem of copying the dll by adding an external property do my libs folder, referencing the build of the dll.
If the external dll is updated very often than you probably need a continuous integration system to handle that for you.

I usually add project reference and keep all my projects under single solution, so I do not have file copy issue. You might be missing project reference, instead you could have used assembly reference. Verify that first.
First advice, don't create a web service if you don't know what it is and how it can be used. People tend to think everything is a web service since creating a web service in WCF is so easy by using visual studio tools. Since you ask like converting DLL to a web service, I assume that you are beginning with learning web service.
All you need is kind of continues integration system otherwise a simple build system which does the build for you and it copies the files wherever depended applications folder. Hence you can save your time for coping files manually. When you do this, you will not have any of those 4 problems you have mentioned.
If you are lazy enough to learn the build system, simply write a batch file that would copy the files for you. I do have batch files which does xcopy files.

Related

C# .net, how to deploy class library dll when using 3rd party component references

This is my first post so here goes...
I have a c# .net class library I've build and been using in production for some time now. The project (using .net framework 3.5, output type Class Library, strongly named) didn't have any non-framework/standard references. It's set to be used as a COM component and we're using it against classic ASP websites. To deploy I'm setting the Build -> Configuration Manager to Release, building, copying the bin/release/PrintJob.dll file to our web servers. I then use regasm "c:\path info\PrintJob.dll" /tlb /codebase to register this on the server. At that point our classic ASP sites can successfully create an instance of the object and use it's functionality.
Today I've been tasked with implementing a new piece of functionality (encryption/decryption) using a 3rd party .net component. I'm used to working with ASP.NET applications more so that class libraries and COM components. So I update my existing project like I would a web project. I have the new dll on my computer, I first had to give it a strong name itself so my class library would accept it, I add the reference to the customCrypto.dll file in my application, reference the namespace in my class file(s), test it, build it, and it works fine locally.
I'm attempting to deploy it using the same method as previously. I go to the bin/release/ folder, copy the PrintJob.dll file to my web servers, register it the same, and when my sites attempt to use it now, it's throwing an exception that it can't find my customCrypto.dll file (the exceptions displays the full strong name assemply attributes).
So my question is am I doing this correctly? In a web project, the customCrypto.dll file is going to be moved along with my site automatically during the publish. So the dll automatically ends up with the project no problem. But with this class library, do I need to also copy the customCrypto.dll file to the other servers? When the build happened, how come my PrintJob.dll assembly didn't include this functionality internally. How do I get the COM component PrintJob.dll to be able to use the customCrypto.dll when deployed? Since the 3rd party customCrypto.dll component is a .net component, should I somehow be adding this to the machine and using it with my application another way?
I've spent the entire day trying to find references to this but all I can find are more direct issues like how to strongly name an assembly, add it as a reference, etc. Any help is greatly appreciated.

Debugging ASP.NET web service, C++/CLI DLL, and native DLL in Visual Studio 2008

I have a VS2008 solution with three projects: C# ASP.NET web service, which is using C++/CLI DLL, which in turn is calling functions of native C++ DLL. All references are properly set. In web service bin folder there are all three DLL's. Problem is when I hit F5 the page in my browser informs me about FileNotFoundException from HRESULT 0x8007007E, The specified module could not be found.
The missing module is my native DLL. ASP.NET Development Server copies (and uses) my C++/CLI DLL somewhere in %USERPROFILE%\AppData\Local\Temp\Temporary ASP.NET Files\root, but not the native one. If I manually copy native DLL to the same folder with C++/CLI DLL then I can debug my web service. However, this copying does not seem right.
Copying native DLL somewhere on PATH does not feel right either, because other developers need to remember it.
There is a similar question here, and a blog post linked in one answer. The given solution requires that I change DLL's to be delay-loaded, which again seems to much of a half-baked workaround, because it requires to change the end product due to development hurdles.
Is there a proper way to debug a combination of web service, C++CLI DLL, and native DLL?
The issue is simply that the compiler can't figure out where the native c++ library is.
So, there are a couple ways to fix that.
Use DLLImport to load the dll using a relative or absolute path at runtime.
Set the path environment variable to it's location.
Get really complicated in how the project is built (see link below, which you've obviously already read).
http://blogs.msdn.com/b/jorman/archive/2007/08/31/loading-c-assemblies-in-asp-net.aspx
There's no real answer beyond those.

ASP.NET - Share code

I have a web application that contains a bunch of classes in the App_Code folder. I compile the project and publish it to the IIS server.
I want to share some of the code in the app_code folder with another application on the server and therefore I think I need to register an assembly in the GAC.
What is the best way to do this? I have read this article: http://msdn.microsoft.com/en-us/library/Aa479044, which suggests a number of options?
Put the code in a class library, and add the library as a project reference to both applications.
Side Note:
If you need to access the request or response, etc. import the Sysyem.Web library and use the HttpContext object. This will give you most, if not all the information available to the page.
You'll have to move the code into a separate project, which will output a library.
If you have any references to dlls related to the ASP .Net or web in general, you can reference them from that library.
The code might not compile in the first, but you can refactor it, it really depends on how tight is with what is in App_Code.
You can then reference that library on the Web Site (you'll have to refactor here too some things). The library, once is signed, can be added to GAC also.
The solution for me was to expose the shared functionality in a web service.

Using Web Setup Project for multiple types of projects

I am trying to a create an installer for my web application. My solution contains several projects. They include:
Class library project (referenced by the web application)
Web Application
Windows Service
Web Services project
Database project (execute update script)
I also have an unmanaged dll (crystal reports) in my web application project, so I might have to do some editing of the registry.
I ideally want to be able to use a web setup project to install the whole solution. Can this be done? Is there a better method/solution?
The short answer is "Yes" it can be done.
Other better solution? Well, I'm not a huge fan of VS.NET's installer/setup, can be kind of bulky, 3rd parties could be better at a price. Having said that, it should be able to satisfy your requirements.

How do you track down dependencies for ASP.NET Web Site?

The dynamic compile-on-the fly approach seems to fall outside the capacity for the typical tools which would extract this kind of information. I know I may be better off converting to a Web Application, BUT I would like to ask how it could be done in the case of a Web Site Project.
The aspnet_compiler can still leave you with a boatload of assemblies to scan. You can chase it with aspnet_merge, or use a Web Deployment Project to run the compiler and merge utility for you. WDP can give you a single assembly for the entire web site.
You could always use the aspnet_compiler and then scan for dependencies on the compiled assemblies.

Resources