Guest User

Untitled

a guest
Jan 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. if (WebConfigSettings.ComPartition == null && HttpContext.Current != null)
  2. Nses = new NSession();
  3. else
  4. Nses = (INSession)Marshal.BindToMoniker(string.Format("partition:{0}/new:NuntioServer.NSession", WebConfigSettings.ComPartition));
  5.  
  6. if (WebConfigSettings.ComPartition == null && HttpContext.Current != null)
  7. apses.Wses = new WSession();
  8. else
  9. apses.Wses = (IWSession)Marshal.BindToMoniker(string.Format("partition:{0}/new:NuntioServer.WSession", WebConfigSettings.ComPartition));
  10.  
  11. public static TInterface Get<TSubInterface, TInterface>() where TSubInterface: TInterface
  12. {
  13. <snip></snip>
  14. if (!useComPartitions)
  15. return Activator.CreateInstance<TSubInterface>(); // --> this is not cooperating
  16.  
  17. return (TInterface)Marshal.BindToMoniker(.....);
  18. }
  19.  
  20. class Program {
  21. static void Main(string[] args) {
  22. var shl = new Shell32.Shell();
  23. }
  24. }
  25.  
  26. .method private hidebysig static void Main(string[] args) cil managed
  27. {
  28. .entrypoint
  29. // Code size 8 (0x8)
  30. .maxstack 1
  31. .locals init ([0] class [Interop.Shell32]Shell32.Shell 'shl')
  32. IL_0000: nop
  33. IL_0001: newobj instance void [Interop.Shell32]Shell32.ShellClass::.ctor()
  34. IL_0006: stloc.0
  35. IL_0007: ret
  36. } // end of method Program::Main
  37.  
  38. var coClassAttribute = type.GetCustomAttribute<CoClassAttribute>(); // our extension method
  39. return (TSubInterface)Activator.CreateInstance(coClassAttribute.CoClass);
Add Comment
Please, Sign In to add comment