Using CodeSite 5.1 in a C# DLL project

Have a CodeSite question that doesn't fit into any of the forums below? Post it here.

Using CodeSite 5.1 in a C# DLL project

Postby pauld » Wed Mar 07, 2012 9:04 am

I've mainly used CodeSite with Delphi. I really have only done a small amount of C# and .NET development. But, I've done a little work on C# projects that create DLLs. I have not been able to get CodeSite to work.

I have done the little "My first message" C# tutorial in the help, a Windows Forms application. And that works. But, it just doesn't work for my DLL application.

I don't fully understand all the linkage of these .NET assemblies work. The times I've worked on C# DLL's, I've been given a template project, one that generates a basic working DLL with empty processing. So, I haven't really had to learn how to do too much with C# beyond the specific processing code I had to add, so I presume that is most of my problem.

Anyway, to my DLL application, in the project properties, the target framework is .NET 2.0 and the output type is class library. I added the codesite assembly. It wouldn't link until I also added the System.Drawing assembly. I added that, and it would link. But, when a CodeSite.Send() call is attempted, I get an "Execution failed. The socket connection was aborted. This could be caused by... etc..."

Any idea?
pauld
 
Posts: 2
Joined:
Fri May 06, 2011 1:05 pm

Re: Using CodeSite 5.1 in a C# DLL project

Postby Raize Support » Thu Mar 08, 2012 1:48 am

Hi,

In C#, a class library, is just another assembly. A .NET assembly is similar to a Delphi package in that is has all the additional symbol information to handle the objects/classes defined in the assembly. A Delphi package has the BPL extension, but it could just as easily have a DLL extension. In .NET, assemblies simply use the DLL extension.

Anyway, I did the following to test out this situation. I started by creating a Windows Forms applications. This created a new project and has a blank form. I then added to the solution a new Class Library. This creates a new project in the solution for ClassLibrary1. I then added the Raize.CodeSiteLogging assembly to the References section of the Class Library. In the Class1.cs source file, I then added the using Raize.CodeSiteLogging statement at the beginning of the module. I then created a new public method in the Class1 class, called SampleMethod. This method simply calls CodeSite.Send( "Test Message" );

Next, I went back to the Windows Forms application and added the ClassLibrary1 assembly to the References section. You can find the ClassLibrary1 assembly in the Projects tab of the References dialog. Next, then I added the "using ClassLibrary1" statement to the source file. Next, I dropped a button on the form. In the button click event handler I entered the following:
Class1 c1 = new Class1();
c1.SampleMethod();

I then built the app, and when I click the button, the CodeSite message shows up in the viewer.

So, going back to your particular situation, what kind of application have you built that is using your assembly? Is it a WinForms or WPF app? Are you by chance creating a Silverlight app to use your class library assembly? If so, this is most likely the reason for the error. The core .NET assemblies a different for Silverlight and is not currently compatible with the Raize.CodeSiteLogging assembly.

Ray
Raize Software Support
Raize Software
http://www.raize.com
Raize Support
 
Posts: 622
Joined:
Fri Mar 25, 2011 9:04 pm

Re: Using CodeSite 5.1 in a C# DLL project

Postby pauld » Thu Mar 08, 2012 3:24 am

Sorry for my ignorance. If you can't help me too much because of my own ignorance, I can understand. But, I'll try to give more information.

One thing I am certain of, we are NOT using Silverlight. The way our product is archetected, we have a standard format that our business logic modules must comply to. Developers of the business logic modules are given a C# Visual Studio template project to start with. There is a section where you define what inputs and what output parameters the module will expect. So, typically, a developer of a business logic module needs to know very little about anything else except what inputs and outputs they need, and what the actual business logic is to compute.

We do have, as you might expect, our own rudimentary debug logging feature. Much like the old 'printf' standby. I've made due with that, though I had hoped to be able to try to use CodeSite instead.

We also have a service (installed in the Windows Services) that acts as an intermediary between a the module providing the business logic, and the applications that use it. Why we need this intermediary service, I haven't a clue. We also are given a test client. This client application will be able to call any business logic module that complies with our standard. Its a simple Windows application that you first select the business logic module you want to run. Then you get a grid where you can type in your test values, hit execute, and you then get a results grid.

I don't even know what this test client application is written in. It is my guess it is just a C# winforms application. I can say it looks like any other basic Windows application.

At any rate, the business logic modules normally do not have any windows or screen I/O. They are just logic modules. That is why System.Drawing wasn't in my references list.

I seem to remember asking you a fairly similar question back on your old forums. I was working on a totally different product from a totally different vendor with no relationship whatsoever to my current issue. But, it was similar at least in the fact that the product was designed to be extensible with C# modules. I don't remember what specific errors I had there were, if it was the same error or a different error. But I can say that I couldn't get that to work either.
pauld
 
Posts: 2
Joined:
Fri May 06, 2011 1:05 pm

Re: Using CodeSite 5.1 in a C# DLL project

Postby Raize Support » Fri Mar 09, 2012 1:12 am

Hi Paul,

Thanks for the information. As I tried to explain in my previous post, CodeSite can be used in a Class Library DLL (i.e. Assembly). For your particular situation, there are still some unknown questions. First, something needs to be loading your assembly in order to call any of the methods (of classes) that you have defined in the assembly. You mention a Client Application and a Windows Service. Which one of these is actually loading your assembly?

It sounds like the Client Application is, but perhaps it is passing it on to the Windows Service. The interesting thing about Windows Services is that they run in a different Window Station from the user's Desktop. When using CodeSite from a Windows Service, you need to change the method CodeSite uses to connect to the Dispatcher. Specifically, the ConnectUsingTcp() method needs to be called. This is documented in the CodeSite Help in the section on Logging from Services in the Advanced Techniques section.

The other interesting aspect of your issue is the actual error from the original post. That is, the "Execution failed. The socket connection was aborted....". Were you already calling the ConnectUsingTcp() method. By default, the ConnectUsingTcp() method is NOT called and no TCP code is executed. So, unless you are already calling ConnectUsingTcp, there is no reason why the CodeSite assembly would be using a socket. If you are using ConnectUsingTcp, is your firewall blocking the port that is being used (default 3434).

Ray
Raize Software Support
Raize Software
http://www.raize.com
Raize Support
 
Posts: 622
Joined:
Fri Mar 25, 2011 9:04 pm


Return to General

Who is online

Users browsing this forum: No registered users and 2 guests

cron