Click here to Skip to main content
15,885,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Issue: IN windows form Application,
Application is deployed on three server, on two server same users are able to access the feature of application. But when users try to access same feature in the application remaining one out of three server
Getting this error on click to access required feature

'Exception 1  Message:Exception has been thrown by the target of an invocation.
Stack trace:at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)     
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)     
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)     
at System.Activator.CreateInstance(Type type, Boolean nonPublic)     
at System.Activator.CreateInstance(Type type)     
at SOLVWorkSpace.utilities.openNonDuplicateForm(Type newForm, Form senderForm, Boolean openForm, String customWindowBarText, String priceListKey)     
at SOLVWorkSpace.frmMdiMain.openForm_Click(Object sender, EventArgs e)     
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)     
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)     
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)     
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)     
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)     
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)     
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)     
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)     
at System.Windows.Forms.Control.WndProc(Message& m)     
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)     
at System.Windows.Forms.ToolStrip.WndProc(Message& m)     
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)     
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)     
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)    
Exception 2  Message:Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))    
Stack trace:   at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)     
at System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)     
at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)     
at System.Windows.Forms.AxHost.CreateInstance()     
at System.Windows.Forms.AxHost.GetOcxCreate()     
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)     
at System.Windows.Forms.AxHost.CreateHandle()     
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)     
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)     
at System.Windows.Forms.AxHost.EndInit()     
at SOLVWorkSpace.frmSurLtp.InitializeComponent()     
at SOLVWorkSpace.frmSurLtp..ctor()    '


Kindly suggest any idea or clue why it is.

Thanks in advance

What I have tried:

tried to find out "
System.RuntimeType.CreateInstanceSlow()"

Having doubt on it , a per stack trace , but couldn't get any solid solution.
as already mentioned that two out of three , it is working , but on one server is throwing this exception.
Posted
Comments
Richard MacCutchan 18-Jun-21 8:03am    
The problem is a missing library:
Exception 2  Message:Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

You need to check to see which component you are trying to access.
SeeSharp2 18-Jun-21 8:51am    
As Richard said, "Class not registered" means something is not installed properly or is missing.
FullStackVale 21-Jun-21 7:52am    
HI @Richard MacCutchan
any way to figure out which class is not registered ?

As per stack trace , in our code side
if (!string.IsNullOrEmpty(priceListKey))
{
frm = (Form)Activator.CreateInstance(newForm, priceListKey);
var propertyExist = frm.GetType().GetProperty("priceListKey");
if (propertyExist != null)
frm.GetType().GetProperty("priceListKey").SetValue(frm, priceListKey);
}
this the peice code where we considering code is breaking

Note: Issue on specific server
FullStackVale 22-Jun-21 8:08am    
Hello @Richard and @DevParty, I have update my issue with more details, hope it will helpful in diagnose the issue.

Application: Windows form Application,
Server: 2016 windows server
Plateform: server 64 bit

Our Window form application is throwing following exception only on one server for specific feature to access on click of button(all other features are accessible and working fine on this same server for same application).

Note: Same winform application with all same feature are working fine on other two server(with same configuration).

**Exception:**`enter code here`
System.Runtime.InteropServices.COMException (0x80040154): Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
at System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstance()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.AxHost.EndInit()
at SOLVWorkSpace.frmSurLtp.InitializeComponent()
at SOLVWorkSpace.frmSurLtp..ctor()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900