static RuntimePolicyHelper() { var clrRuntimeInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject( Guid.Empty, typeof(ICLRRuntimeInfo).GUID); TryGetRuntimePolicy(clrRuntimeInfo); }
private void POS_Product() { webHandler.POS_Get_ProductAsync(); webHandler.POS_Get_ProductCompleted += (x, y) => { var result = y.Result; product.ProductsCollection = new ObservableCollection <ProductsModel>(); string[] arr = result.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in arr) { string[] arg = item.Split(new string[] { "---" }, StringSplitOptions.None); product.ProductsCollection.Add(new ProductsModel() { Productid = arg[0], ProductName = arg[1], ProductCatagoryid = arg[2], ProductCatagoryDesc = arg[3], ProductPrice = arg[4], ProductStatusid = arg[5], ProductStatusDesc = arg[6], ProductQuantity = arg[7], ProductDesc = arg[8], ProductBuyingPrice = arg[9], ProductProfit = arg[10], }); } try { ICLRRuntimeInfo rtInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID); rtInfo.BindAsLegacyV2Runtime(); report.Load("../../CrystalReport1.rpt"); report.SetDataSource(from c in product.ProductsCollection select new { c.Productid, c.ProductName, c.ProductCatagoryDesc, c.ProductPrice, c.ProductStatusDesc, c.ProductBuyingPrice, c.ProductQuantity }); crystalReportsViewer1.ViewerCore.ReportSource = report; } catch (Exception e1) { Debug.WriteLine("Kush hua hai "); Debug.WriteLine(e1.Message); } //ReportDocument report2 = new ReportDocument(); //report2.Load("../../CrystalReport2.rpt"); //report2.SetDataSource(from c in product.ProductsCollection // select new { c.Productid, c.ProductName, c.ProductCatagoryDesc, c.ProductPrice, c.ProductStatusDesc, c.ProductBuyingPrice, c.ProductQuantity }); //crystalReportsViewer2.ViewerCore.ReportSource = report2; }; }
static RuntimePolicyHelper() { ICLRRuntimeInfo runtimeInterfaceAsObject = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID); try { runtimeInterfaceAsObject.BindAsLegacyV2Runtime(); LegacyV2RuntimeEnabledSuccessfully = true; } catch (COMException exception) { Console.WriteLine(exception.Message); LegacyV2RuntimeEnabledSuccessfully = false; } }
static RuntimePolicyHelper() { var ri = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID); try { ri.BindAsLegacyV2Runtime(); LegacyV2RuntimeEnabledSuccessfully = true; } catch (COMException) { // This occurs with an HRESULT meaning // "A different runtime was already bound to the legacy CLR version 2 activation policy." LegacyV2RuntimeEnabledSuccessfully = false; } }
private void aftermost() { try { ICLRRuntimeInfo rtInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID); rtInfo.BindAsLegacyV2Runtime(); report.Load("../../CrystalReport2.rpt"); report.SetDataSource(from c in product.SaleReportCollection select new { c.Billid, c.Current_DateTime, c.Employee_Name, c.Product_id, c.Product_Name, c.Product_Quantity, c.Optionid, c.Optionname, c.OptionQty, c.Total, DFS, DTS, new LoggedInEmployeeModel().FullName }); crystalReportsViewer2.ViewerCore.ReportSource = report; } catch (Exception e1) { Debug.WriteLine("Kush hua hai "); Debug.WriteLine(e1.Message); } }
private static string[] PeVerify(byte[] peImage, int domainId, string assemblyPath) { lock (s_guard) { GCHandle pinned = GCHandle.Alloc(peImage, GCHandleType.Pinned); try { IntPtr buffer = pinned.AddrOfPinnedObject(); ICLRValidator validator = (ICLRValidator)RuntimeEnvironment.GetRuntimeInterfaceAsObject(s_clsIdClrRuntimeHost, typeof(ICLRRuntimeHost).GUID); ValidationErrorHandler errorHandler = new ValidationErrorHandler(validator); IMetaDataDispenser dispenser = (IMetaDataDispenser)RuntimeEnvironment.GetRuntimeInterfaceAsObject(s_clsIdCorMetaDataDispenser, typeof(IMetaDataDispenser).GUID); // the buffer needs to be pinned during validation Guid riid = typeof(IMetaDataImport).GUID; object metaDataImport = null; if (assemblyPath != null) { dispenser.OpenScope(assemblyPath, CorOpenFlags.ofRead, ref riid, out metaDataImport); } else { dispenser.OpenScopeOnMemory(buffer, (uint)peImage.Length, CorOpenFlags.ofRead, ref riid, out metaDataImport); } IMetaDataValidate metaDataValidate = (IMetaDataValidate)metaDataImport; metaDataValidate.ValidatorInit(CorValidatorModuleType.ValidatorModuleTypePE, errorHandler); metaDataValidate.ValidateMetaData(); validator.Validate(errorHandler, (uint)domainId, ValidatorFlags.VALIDATOR_EXTRA_VERBOSE, ulMaxError: 10, token: 0, fileName: assemblyPath, pe: buffer, ulSize: (uint)peImage.Length); return(errorHandler.GetOutput()); } finally { pinned.Free(); } } }
internal static int Main(string[] args) { Console.WriteLine("START"); var assembly = typeof(Program).Assembly; var assemblyName = new AssemblyName(assembly.FullName); Console.WriteLine("My strong key token: " + BytesToString(assemblyName.GetPublicKeyToken())); var clrStrongName = (IClrStrongName)RuntimeEnvironment.GetRuntimeInterfaceAsObject( new Guid("B79B0ACD-F5CD-409b-B5A5-A16244610B92"), new Guid("9FD93CCF-3280-4391-B3A9-96E1CDE77C8D")); int result = clrStrongName.StrongNameSignatureVerificationEx(assembly.Location, true, out var verified); if (result == 0 && verified) { Console.WriteLine("My signature is valid!"); } Console.WriteLine("END"); return(42); }
private async void aftermost() { try { ICLRRuntimeInfo rtInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID); rtInfo.BindAsLegacyV2Runtime(); var a = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); ReportDocument report = new ReportDocument(); report.Load(a + @"/CrystalReport3.rpt"); CustomerLedgerDataSet ds = new CustomerLedgerDataSet(); DataTable dt1 = ds.BillProduct; DataTable dt2 = ds.Customer; // assume columns have been created foreach (var c in billProductModel.BillCollection) { dt1.Rows.Add(c.DateTime, c.Billid, c.Quantity, c.ProductName, c.Rate, c.TotalAmount, c.Status, c.Balance); } dt2.Rows.Add(selectedCustomer.Customerid, selectedCustomer.CustomerName, selectedCustomer.CustomerLocation, selectedCustomer.Customerbalance, selectedCustomer.CustomerLastTally, selectedCustomer.Customerphone); report.SetDataSource(ds); crystalReportsViewer2.ViewerCore.ReportSource = report; } catch (Exception e1) { var win = (MetroWindow)Application.Current.MainWindow; var res1 = await win.ShowMessageAsync(" source: " + e1.Source, e1.Message + " || " + e1.StackTrace + MessageDialogStyle.Affirmative); Debug.WriteLine(e1.Message); } }
/// <summary> /// Activates the LegacyV2RuntimeActivationPolicy. /// <para/> /// Useful e.g. for unit tests where you have no access to the app.config of the test runner process. /// </summary> public static void Activate() { var clrRuntimeInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID); clrRuntimeInfo?.BindAsLegacyV2Runtime(); }
/// <summary> /// This method locates our per-process app domain and connects to a running /// instance of ComponentManagerBroker. That instance then demand- /// creates an instance of ComponentManagerProxy for the calling thread /// and returns it. /// </summary> internal static UnsafeNativeMethods.IMsoComponentManager GetComponentManager(IntPtr pOriginal) { lock (_syncObject) { if (_broker == null) { // We need the default domain for the process. That's the domain we will use // for all component managers. There is no managed way to get this domain, however, // so we use ICorRuntimeHost. UnsafeNativeMethods.ICorRuntimeHost host = (UnsafeNativeMethods.ICorRuntimeHost)RuntimeEnvironment.GetRuntimeInterfaceAsObject(typeof(UnsafeNativeMethods.CorRuntimeHost).GUID, typeof(UnsafeNativeMethods.ICorRuntimeHost).GUID); int hr = host.GetDefaultDomain(out object domainObj); Debug.Assert(NativeMethods.Succeeded(hr), "ICorRuntimeHost failed to return the default domain. The only way that should happen is if it hasn't been started yet, but if it hasn't been started how are we running managed code?"); AppDomain domain = domainObj as AppDomain; if (domain == null) { Debug.Assert(NativeMethods.Failed(hr) || domain != null, "ICorRuntimeHost::GetDefaultDomain succeeded but didn't retrn us an app domain."); domain = AppDomain.CurrentDomain; } // Ok, we have a domain. Next, check to see if it is our current domain. // If it is, we bypass the CreateInstanceAndUnwrap logic because we // can directly go with the broker. In this case we will create a broker // and NOT remote it. We will defer the remoting until we have a different // domain. To detect this, the _broker static variable will be assigned // a broker in the primary app domain. The CreateInstance code looks at this // and if it is aready set, simply remotes that broker. That is why there // is a "Singleton" property on the broker -- just in case we had to create // a temporary broker during CreateInstanceAndUnwrap. if (domain == AppDomain.CurrentDomain) { _broker = new ComponentManagerBroker(); } } } // However we got here, we got here. What's important is that we have a proxied instance to the broker object // and we can now call on it. return(_broker.GetProxy((long)pOriginal)); }
private static MetadataDispenser.IMetaDataDispenserEx GetDispenserShim() { return((MetadataDispenser.IMetaDataDispenserEx)RuntimeEnvironment.GetRuntimeInterfaceAsObject(typeof(MetadataDispenser.CorMetaDataDispenserExClass).GUID, typeof(MetadataDispenser.IMetaDataDispenserEx).GUID)); }