Profiling medium trust web applications
Our profiler uses WCF in order to communicate with the client application. One of the benefits of the XPOProfiler is that it supports 2 binding types. Both binding types have their advantages however in this situation only one allows us the flexibility we require.
NetTcpBinding
This option provides a secure and reliable binding environment for .Net to .Net cross machine communication. By default it creates a communication stack using WS-ReliableMessaging protocol, TCP for message delivery and windows security for message and authentication at run time.

One drawback is that in shared host environments there is no way to open a port neither to use Mutexes. Our second option allows us to overcome this by creating a WCF service and hosting it with our web application.
WSHttpBinding
-
Defines a secure, reliable, interoperable binding suitable for non-duplex service contracts,
-
Supports WS-* functionality and distributed transactions with reliable and secure sessions using SOAP security,
-
Uses HTTP and HTTPS transport for communication,
-
Reliable sessions are disabled by default

We have already identified limitations when profiling medium trust web applications, now we must look at modifying our application in order to overcome them.
The first step is to add the new service using VS add new Item context menu.
This action will add the following items to the project;
-
IMyLogService.cs - the communication interface description,
-
MyLogService.svc.cs - the communication service class declaration
Furthermore the Web.config file will be modified by adding <system.serviceModel> section. I am using .NET3.5 right now, be aware that this step may vary according to the .NET version you are using.
The next step is to remove the IMyLogService.cs from the project.

Then we are going to modify the MyLogService.svc.cs as follows;
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyLogService : LogService {
public MyLogService()
: base(Logger) {
if (Logger != null) LogManager.SetTransport(Logger);
}
private static LoggerBase Logger {
get { return new LoggerBase(); }
}
}
The final step is to change the name of the communication contract in <system.serviceModel> section of Web.config file from WebApplicationToProfile.IMyLogService to DevExpress.Xpo.Logger.Transport.ILogSource.

After that we are ready to run the XPOProfiler and create a new connection to our medium hosted XPO web application.

Note: Version 11.2 will allow us to carry out all the above processes.
Happy profiling!
Related Links
Blog posts
Videos

