<< This is my python code >>
<< (Step 1) - I am registering the class of this python file for this PythonUtil class by executing this code in the pythonwin.exe interpreter >>
class PythonUtil:
_public_methods_ = ['funct’]
_reg_progid_ = "PythonUtil.Utilities"
_reg_clsid_ = "{73B6791B-C161-4F26-9402-D4AE4BC602AB}"
def funct(self, val, item=None):
print “hi”
if __name__=='__main__':
print "COM server being registered..."
import win32com.server.register
win32com.server.register.UseCommandLine(PythonUtil)
output:
com being registered.
<< (step2) - I am having this code in c# >>
private void button_Click(object sender, EventArgs e)
{
object instance =Activator.CreateInstance(Type.GetTypeFromProgID("PythonUtil.Utilities"));
if (instance != null)
{
Type type = instance.GetType();
for (int y = 0; y < ((checkedListBox1.CheckedItems.Count)); y++)
{
object objRet = type.InvokeMember("SwapCaseString", BindingFlags.Default | BindingFlags.InvokeMethod, null, instance, paramList);
}
}
}
<< (step 3) - executing this c# code , allows me to call the function 'funct' and
It works fine for me >>
----------- Upto here everything is fine --------------------
But my query is,
- I dont want to do the execution process of (Step 1) , instead I need that to be registering the classID process through C# itself.
- Let me make it little bit clear ,
I am allowed to write the code in python , but I cannot execute it in pythonwin.
Instead I have a button click in c#, which will first registers that class or executes that python dynamically and Executes in c#
so for that I need an alternative.
<hope u understand my requirement><please help>