PDA

View Full Version : خطا در استفاده از فايل ocx



r_mehrizi
پنج شنبه 02 مهر 1388, 09:01 صبح
توي برنامه ميخوام از يك فايل ocx به نام checkdigit استفاده كنم كه براي چك كردن كد ملي هست
با استفاده از add refrence فايل ocx را به برنامه اضافه كردم
داخل اين فايل ocx يك تابع به اسم
validateNIDNumber هست كه ورودي اون كدملي هست اگر اين كد ملي وجود داشت true برگردونده ميشه و گر نه false
من اين كدها را توي برنامه نوشتم اما وقتي اجرا ميشه خطا ميده


ProtectedSub b_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles b.Click
Dim ckdigit As CHECKDIGITLib.CheckDigit = New CHECKDIGITLib.CheckDigit
Dim codemeli AsString = "1234567890"

Dim t AsBoolean = ckdigit.validateNIDNumber(codemeli)
Me.TextBox1.Text = t
EndSub



پيغام خطايي كه ميده اين هستش

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

Source Error:


Line 9: Dim codemeli As String = "1234567890"Line 10: 'Dim t As Boolean = CHECKDIGITLib.CheckDigit.validateNIDNumber(codemel i)Line 11: Dim t As Boolean = ckdigit.validateNIDNumber(codemeli)Line 12: Me.TextBox1.Text = tLine 13: End Sub

Source File: c:\inetpub\wwwroot\salb\pages\codemeli.aspx.vb Line: 11

اين فايل ocx كه ميخوام استفاده كنم قبلا توي برنامه vb استفاده ميشده
خيلي ضرووري هستش خواهشا يك نفر راهنمايي كنه:عصبانی++:

kiosksoft
پنج شنبه 02 مهر 1388, 10:42 صبح
دوست عزیز

این خطا دلایل متفاوتی میتونه داشته باشه . در سایت مایکروسافت هم در موردش بحث شده است.

اما در کد شما از ActiveX درست استفاده نشده است یعنی در کل این خطا منطقی هستش!

شما بصورت public این خط کد رو تعریف کنید :


Dim ckdigit As CHECKDIGITLib.CheckDigit = New CHECKDIGITLib.CheckDigit

بعد در قسمت _Load برنامه این کد رو وارد کنید :




Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Controls.Add(ckdigit )
End Sub



انشاالله مشکلتون حل میشه . نشد ActiveX رو بزارید اینجا بررسی کنیم.

r_mehrizi
پنج شنبه 02 مهر 1388, 10:50 صبح
كارهايي كه گفتيد كردم خطاي زير را ميده

Unable to cast COM object of type 'CHECKDIGITLib.CheckDigitClass' to class type 'System.Web.UI.Control'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast COM object of type 'CHECKDIGITLib.CheckDigitClass' to class type 'System.Web.UI.Control'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.

Source Error:

Line 6: Line 7: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadLine 8: Controls.Add(ckdigit)Line 9: End SubLine 10:
Source File: c:\inetpub\wwwroot\salb\pages\codemeli.aspx.vb Line: 8

kiosksoft
پنج شنبه 02 مهر 1388, 10:54 صبح
لطفا ActiveX رو به هر طریق که صلاح میدونید ارسال کنید

kiosksoft
شنبه 04 مهر 1388, 09:36 صبح
دوست عزیز

ActiveX شما در محیط vb6 مشکل نداره اما برای استفاده در دات نت با مشکل مواجه میشه. در واقع برای استفاده از سمت کلاینت کار میکنه اما باید سمت هر کلاینتی که استفاده میشه باید رجیستر بشه! برای اینکه راحت تر بتونید با این مسئله بخورد کنید و وابسته به dll و ocx نباشید در تاپیک ذیل کامل در مورد روش تشخیص صحت کد ملی و الگوریتم آن, بررسی و آورده شده است :
http://barnamenevis.org/forum/showthread.php?t=180515