Παρουσίαση με Ετικέτες

Profiling medium trust web applications
29 Αυγούστου 11 10:07 πμ | tolisss | 0 σχόλια   

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.

image

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

image

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.

image

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.

image

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.

image

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

image

Note: Version 11.2 will allow us to carry out all the above processes.

Happy profiling!

Related Links
Blog posts
Videos


Δημοσίευση στην κατηγορία: ,
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM
05 Μαΐου 10 09:56 πμ | tolisss | 0 σχόλια   
When you try assign a only time to a datetime and save it you are going to get an an exception like the one in the subject. i have added to eXpand an SqlDateTimeOverFlowValueConverter to help you deal with that public class SqlDateTimeOverFlowValueConverter : ValueConverter {     public override Type StorageType {         get { return typeof ( DateTime ); }     }       public override object ConvertToStorageType( object value) {         if (value!= null ) {             var dateTime = new DateTime (1753, 1, 1);             if (dateTime>(

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία:
Xaf tip # 6 Linq your Session queries
17 Σεπτεμβρίου 09 04:07 μμ | tolisss | 0 σχόλια   
Pretty silent these days eh? I am working on a big refactoring on DictionaryDifference and have not much time to blog. But have another tip for my Xaf Tips series today maybe not strictly Xaf but is an XPO tip that you can use with your Xaf applications . The Problem Suppose your are a strongly typed fun like me or you want to use linq to query objects inside a transaction. In order linq to be used with XPO DevExpress provides XPQuery<T> class but unfortunately this do not support transactions. So the following test fails var work = new UnitOfWork(); new User(work){UserName = "Sam" }; User firstOrDefault = new XPQuery<User>(work).Where(user => user.UserName == "Sam" ).FirstOrDefault(); Assert.IsNotNull(firstOrDefault); The solution

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία: , , ,
CodeSmith templates for Xaf
30 Ιουνίου 09 11:39 πμ | tolisss | 0 σχόλια   
Yes I know that is not the best practice. When using Xaf or Xpo you should first design your objects and let the framework create the database schema based on objects metadata (attributes). But there are many cases that the database is already design and you can not change it. What about those projects? Are you going to say to your customer that you do not want that project? Are you going to sit down and write all classes by hand? The best solution on this is to use some Template engine like Codesmith to create the initial implementation for you and then you can change them to meet your needs. You can also find a freeware version of Codesmith here Devexpress also has a persistent class generation Util which ca be invoked from the add new item form    

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία: , , , ,
Xpo Properties for Strongly Typed freaks!!!
16 Ιουνίου 09 05:03 μμ | tolisss | 0 σχόλια   
Because XPbaseObject implements INotifyPropertyChanged property setters need to be implemented using a special way like public   string Name {     get     {         return name;     }     set     {         SetPropertyValue( "Name" , ref name, value);     } } but if you are a strongly typed fun like me the you certainly will not like the string representation of the “Name” as a parameter of SetPropertyValue because if you rename the property then you should explicitly rename the string parameter as well. I used to write my properties like private   string nameWithReflection; public  

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία: , ,
Validation Rule: At least one property is required
03 Ιουνίου 09 01:33 πμ | tolisss | 0 σχόλια   
Today i stump again upon the same problem . I wanted to throw a validation exception only if both of my properties do not have value. So lets create a validation rule for this one. More info on how we create custom validation rules can be found here Validation Module Since we are talking about multiple property values i think we should go with an attribute that is applied to a class and not to a property. Ok first we have to define that both our RuleBaseAttribute and RuleBaseProperties derived classes will implement . public interface IRuleRequiredForAtLeast1PropertyProperties { string MessageTemplateMustNotBeEmpty { get; set; } string Delimiters { get; set; } string TargetProperties { get; set; } } ok that looks nice lets explain what we have here for a bit.

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία: , , ,
Automatic properties for Xpo
02 Ιουνίου 09 05:23 πμ | tolisss | 0 σχόλια   
  The problem Xpo in order to support transactions implements some special kind of property setters like private string lastName; public string LastName { get { return lastName; } set { string oldValue = lastName; if (oldValue == value) return; lastName = value; OnChanged("Name", oldValue, value); } } Or a little more elegant like private string lastName; public string LastName { get { return lastName; } set { SetPropertyValue("LastName", ref lastName, value); } } Imagine you want to Design a fairly simple model like Customer –> Orders. A Customer should have LastName, FilrstName, Age and Orders as properties and Order only an Amount property. Using the above approach one could write the following code to describe the above model.

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία: , , , ,

Search

Go

Το Ιστολόγιο

Ιστορικό Δημοσιεύσεων

Συνδρομές