Results 1 to 3 of 3

Thread: Weirdest Error - Cannot widen from target type to primitive type.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Location
    Troy, 0hi0
    Posts
    10

    Weirdest Error - Cannot widen from target type to primitive type.

    Okay, I have a solution with many forms. I also have two namespaces where I have about 20 different objects. Everything is going great til I add this one form. Now, on my task list I have two errors that say "Cannot widen from target type to primitive type.". When I double click them to goto the error it takes me to line one of the form (whether there are any Imports or not). I can't figure this out. The only other different from that form is that the Sub New() looks like this Sub New(ByVal n as NoteBook). The NoteBook object is taken from my Namespace which is Imported at the top of the form. I also am calling the ShowDialog() event.

    dim frm as New frmPassword(myNotebook)
    frm.ShowDialog()

    Even if I take out my modified Sub New() and all references to Objects in my Namespace I still get the same 2 errors "Cannot widen from target type to primitive type." both of which, as I said take me to line one of that form.

    I tried compiling this code and it runs great on my computer, however when application is ran on another computer (which is exactly the same as mine, other than minus visual studio, same OS (XP Pro), same RAM, processor, etc) the form will "flash" on and then disappear. You can see that it loaded the dialog box but then it's mysteriously gone.

    I have searched the MSDN, and every forum I'm aware of for the "Cannot widen from target type to primitive type." error and I can't find anything. I would appreciate any help or insight to this problem. Thanks alot!
    Last edited by bergy; Jan 19th, 2004 at 11:09 PM.

  2. #2

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Location
    Troy, 0hi0
    Posts
    10

    Code

    Here is my form:

    VB Code:
    1. Imports SmartNote.SmartObjects
    2. Imports SmartNote.BookIntegration
    3.  
    4. Public Class frmSecurity
    5.     Inherits System.Windows.Forms.Form
    6.     Public nb As New Notebook()
    7.     Private justclickedit As Boolean = False
    8.  
    9. #Region " Windows Form Designer generated code "
    10.  
    11.     Public Sub New(ByVal nards As Notebook)
    12.         MyBase.New()
    13.  
    14.         'This call is required by the Windows Form Designer.
    15.         InitializeComponent()
    16.  
    17.         'Add any initialization after the InitializeComponent() call
    18.         nb = nards
    19.     End Sub
    20.  
    21.     'took out the form designer junk
    22.     'Form overrides dispose to clean up the component list.
    23.  
    24.     'Required by the Windows Form Designer
    25.     Private components As System.ComponentModel.IContainer
    26.  
    27.     'NOTE: The following procedure is required by the Windows Form Designer
    28.     'It can be modified using the Windows Form Designer.  
    29.     'Do not modify it using the code editor.
    30.    
    31.  
    32. #End Region
    33.  
    34.     Private Sub chkHelp_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkHelp.CheckedChanged
    35.         If chkHelp.Checked = True Then
    36.             Me.Height = 263
    37.         Else
    38.             Me.Height = 168
    39.         End If
    40.     End Sub
    41.  
    42.     Private Sub frmSecurity_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    43.         If nb.Security.IsProtected = True Then
    44.             chk_Password.Checked = True
    45.             txtPassword.Enabled = True
    46.             txtConfirm.Enabled = True
    47.             Dim crypter As New Crypto(Crypto.Providers.DES)
    48.             Dim pass As String = crypter.Decrypt(nb.Security.Password, smartKEY)
    49.             txtPassword.Text = pass
    50.             txtConfirm.Text = pass
    51.         Else
    52.             chk_Password.Checked = False
    53.             txtPassword.Enabled = False
    54.             txtConfirm.Enabled = False
    55.         End If
    56.  
    57.         If nb.Security.IsSerialized = True Then
    58.             chkSerial.Checked = True
    59.         Else
    60.             chkSerial.Checked = False
    61.         End If
    62.         Me.DialogResult = DialogResult.Cancel
    63.     End Sub
    64.  
    65.     Private Sub txtPassword_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPassword.Leave
    66.         If txtPassword.Text = "" And justclickedit = False Then
    67.             chk_Password.Checked = False
    68.             txtPassword.Enabled = False
    69.             txtConfirm.Enabled = False
    70.         End If
    71.         justclickedit = False
    72.     End Sub
    73.  
    74.     Private Sub txtConfirm_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtConfirm.Leave
    75.         If txtPassword.Text <> txtConfirm.Text Then
    76.             MsgBox("Your passwords do not match.", MsgBoxStyle.Critical, "Security Error")
    77.             txtPassword.Text = ""
    78.             txtConfirm.Text = ""
    79.             txtPassword.Select()
    80.         Else
    81.             nb.Security.IsProtected = True
    82.             nb.Security.Password = txtPassword.Text
    83.         End If
    84.     End Sub
    85.  
    86.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    87.         If chkSerial.Checked = True Then
    88.             nb.Security.IsSerialized = True
    89.             Dim r As New rRegistry()
    90.             Dim sN As String = r.QueryValue(rRegistry.ERegistryPossibleRoots.HKEY_CURRENT_USER, "Software\Legal Info-Graphics\SmartNote", "serial", "NULL")
    91.             If sN = "NULL" Then
    92.                 MsgBox("Error finding Serial Number...")
    93.                 nb.Security.IsSerialized = False
    94.                 chkSerial.Checked = False
    95.             Else
    96.                 Dim crypter As New Crypto(Crypto.Providers.DES)
    97.                 Dim theserial As String = crypter.Encrypt(sN, smartKEY)
    98.                 nb.Security.SerialNumber = theserial
    99.             End If
    100.         End If
    101.  
    102.         If chk_Password.Checked = True Then
    103.             If txtPassword.Text <> txtConfirm.Text Then
    104.                 MsgBox("Your passwords do not match.", MsgBoxStyle.Critical, "Security Error")
    105.                 txtPassword.Text = ""
    106.                 txtConfirm.Text = ""
    107.                 txtPassword.Select()
    108.             Else
    109.                 nb.Security.IsProtected = True
    110.                 Dim crypter As New Crypto(Crypto.Providers.DES)
    111.                 Dim thepass As String = crypter.Encrypt(txtPassword.Text, smartKEY)
    112.                 nb.Security.Password = thepass
    113.             End If
    114.         End If
    115.         Me.DialogResult = DialogResult.OK
    116.         tempNoteBookforSecurity = nb
    117.     End Sub
    118.  
    119.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    120.         Me.DialogResult = DialogResult.Cancel
    121.         Me.Close()
    122.     End Sub
    123.  
    124.     Private Sub chk_Password_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chk_Password.CheckStateChanged
    125.         If chk_Password.Checked = True Then
    126.             txtPassword.Enabled = True
    127.             txtConfirm.Enabled = True
    128.             txtPassword.Select()
    129.         Else
    130.             txtPassword.Enabled = False
    131.             txtConfirm.Enabled = False
    132.         End If
    133.         justclickedit = True
    134.     End Sub
    135.  
    136.     Private Sub txtPassword_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPassword.Enter
    137.         justclickedit = False
    138.     End Sub
    139. End Class

  3. #3
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    There are some help in the web about this, and the suggestions:

    Aren't you using an Integer value, for instance, where a Short or Byte is expected??
    Isn't any file in your project Read Only?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width