Hi Jan, I don't know whether you figured it out yourself in the meantime, but I have had the same problem today and made it work. So I just wanted to share my brilliance with you... :-)
Here you go: clr.GetClrType(CalculatorService) The clr object offers the "GetClrType" method which returns the type. I used it in a different context though: XML (De-)Serialization. Worked very well. Let me know whether you had success... - Sebastian Jan R-2 wrote: > > Hello IronPython Experts. > > > How to do the typeof( ) call on an IronPython implemented class in C#? > > The need to do a typeof(..) comes from implementing services in Windows > Communication Foundation (WCF) in IronPython. The WCF get-statrted sample > uses the overloaded constructor of the ServiceHost class that takes a > System.Type: > > ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), > baseAddress); > > > I want to replace the CalculatorService with a IronPython class > PyCalculator. Note the typeof(...). > > I have tried the following without success, in order to give an instance > of > the IronPython class to the ServiceHost constructor : > > ICalculator pyCalc = (ICalculator)pyr.getInstance("PyCalculator"); > ServiceHost selfHost = new ServiceHost( (object) pyCalc, baseAddress); > > The IronPython class is attached below. The code results in an exception, > because the attribute InstanceContextMode have to be set to > InstanceContextMode.Single. > > The WCF get-started sample is here: > http://msdn.microsoft.com/da-dk/library/ms734712(en-us).aspx > > Can anyone help me out? > > > Regards > Jan Rouvillain > > IronPython code: > > import clr > clr.AddReference('CalculatorServer') > from Microsoft.ServiceModel.Samples import ICalculator > > class PyCalculator(ICalculator): > "Implements calculator services" > > def Add(self, a, b): > print 'a ' + a + ' + b ' + b > return a+b > > def Subtract(self, a, b): > print 'a ' + a + ' - b ' + b > return a-b > > def Multiply(self, a, b): > print 'a ' + a + ' * b ' + b > return a*b > > def Divide(self, a, b): > print 'a ' + a + ' // b ' + b > return a/b > > C# interface declaration: > > namespace Microsoft.ServiceModel.Samples > { > [ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")] > public interface ICalculator > { > // Step7: Create the method declaration for the contract. > [OperationContract] > double Add(double n1, double n2); > [OperationContract] > double Subtract(double n1, double n2); > [OperationContract] > double Multiply(double n1, double n2); > [OperationContract] > double Divide(double n1, double n2); > } > } > > _______________________________________________ > Users mailing list > Users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- View this message in context: http://www.nabble.com/How-to-do-the-typeof%28-%29-call-on-an-IronPython-implemented-class-in-C---tp22055752p22532007.html Sent from the IronPython mailing list archive at Nabble.com. _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com