Blackvelvet Posted March 28, 2012 Report Share Posted March 28, 2012 Olá a todos Value cannot be null. Parameter name: objectType Este erro apareceu-me ontem. Pesquisei pela net e pelo que vi e entendi era problema da tabela, ja criei outra,mas o problema persiste Alguem me sabe dizer o porque e como resolver? Cumprimentos Link to comment Share on other sites More sharing options...
Caça Posted March 28, 2012 Report Share Posted March 28, 2012 Mostra o código e onde dá o erro. Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
Blackvelvet Posted March 28, 2012 Author Report Share Posted March 28, 2012 No codigo não dá erro. aparte do desing é que desaparece. Depois clico em "Ignore and continue" e ja mostra o desing todo na mesma. E funciona sem problemas. Mas assim que se abre novamente o VS,aparece novamente o erro. To prevent possible data loss before loading the designer, the following errors must be resolved: 1 Error Ignore and Continue Value cannot be null. Parameter name: objectType Instances of this error (1) 1. Show Call Stack at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.GetRuntimeType(Type objectType) at System.ComponentModel.TypeDescriptionProvider.GetRuntimeType(Type reflectionType) at Microsoft.VisualStudio.Design.MultiTargetingContextProvider.GetRuntimeType(Type objectType) at Microsoft.VisualStudio.Design.Serialization.CodeDom.HandlesClauseManager.GetFieldType(String fieldName, Type documentBaseType) at Microsoft.VisualStudio.Design.Serialization.CodeDom.HandlesClauseManager.GetReferencedComponentType(String componentName, CodeTypeDeclaration codeTypeDecl, ITypeResolutionService loader, IDictionary& cache) at Microsoft.VisualStudio.Design.Serialization.CodeDom.HandlesClauseManager.ParseHandlesClauses(CodeTypeDeclaration codeTypeDecl, Boolean updateCache) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.OnMethodPopulateStatements(Object sender, EventArgs e) at System.CodeDom.CodeMemberMethod.get_Statements() at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload) Help with this error MSDN Help Forum posts about this error Search the MSDN Forums for posts related to this error Aqui deixo o codigo completo do desing Imports System.IO Imports System.Data.SqlClient Imports System.Data.SqlClient.SqlCommandBuilder Public Class registo Dim stringconnection As String Dim sql As String Private Sub btnOk_Click(sender As System.Object, e As System.EventArgs) Handles btnOk.Click Try ' Texto de ligação à base de dados Dim myConnectionString As String = _ "Data Source=.\SQLEXPRESS; Initial Catalog=GestInformatica; Integrated Security=SSPI;" ' Comando que irá inserir dados na tabela "GestInformatica" os campos 'que são passados através de parâmetros Dim SQL As String = "INSERT INTO gestao ([empresa],[nome_rede],[utilizador],[local],[departamento],[visivel_rede],[sistema_operativo],[selo_windows],[office],[licenca],[numero_office],[autenticacao],[office_audit],[dl],[server_cal],[ex_cal],[sql_cal],[user_baan],[user_citrix],[user_internet],[observacao]) VALUES (@empresa, @nome_rede,@utilizador,@local,@departamento,@visivel_rede,@sistema_operativo,@selo_windows,@office,@licenca,@numero_office,@autenticacao,@office_audit,@dl,@server_cal,@ex_cal,@sql_cal,@user_baan,@user_citrix,@user_internet,@observacao);" ' Cria uma nova ligação à base de dados Dim connection As New SqlConnection(myConnectionString) ' Criação do comando indicando a instrução e a ligação Dim command As New SqlCommand(SQL, connection) ' Indicação dos parâmetros que serão inseridos command.Parameters.Add("@empresa", SqlDbType.VarChar).Value = txtEmpresa.Text command.Parameters.Add("@nome_rede", SqlDbType.VarChar).Value = txtNomeRede.Text command.Parameters.Add("@utilizador", SqlDbType.VarChar).Value = txtUtilizador.Text command.Parameters.Add("@local", SqlDbType.VarChar).Value = txtLocalizacao.Text command.Parameters.Add("@departamento", SqlDbType.VarChar).Value = txtDepartamento.Text command.Parameters.Add("@visivel_rede", SqlDbType.Int).Value = cbxVisivel_Rede.SelectedIndex command.Parameters.Add("@sistema_operativo", SqlDbType.VarChar).Value = txtSO.Text command.Parameters.Add("@selo_windows", SqlDbType.VarChar).Value = txtSeloWindows.Text command.Parameters.Add("@office", SqlDbType.VarChar).Value = txtOffice.Text command.Parameters.Add("@licenca", SqlDbType.VarChar).Value = txtSeloOffice.Text command.Parameters.Add("@numero_office", SqlDbType.Int).Value = txtNOffice.Text command.Parameters.Add("@autenticacao", SqlDbType.VarChar).Value = cbxLegal.Text command.Parameters.Add("@office_audit", SqlDbType.VarChar).Value = txtOfficeAuditoria.Text command.Parameters.Add("@dl", SqlDbType.VarChar).Value = cbxDL.Text command.Parameters.Add("@server_cal", SqlDbType.Int).Value = cbxServer.SelectedIndex command.Parameters.Add("@ex_cal", SqlDbType.Int).Value = cbxEX.SelectedIndex command.Parameters.Add("@sql_cal", SqlDbType.Int).Value = cbxSQL.SelectedIndex command.Parameters.Add("@user_baan", SqlDbType.VarChar).Value = cbxUserBaan.Text command.Parameters.Add("@user_citrix", SqlDbType.VarChar).Value = cbxUserCitrix.Text command.Parameters.Add("@user_internet", SqlDbType.VarChar).Value = cbxUserInternet.Text command.Parameters.Add("@observacao", SqlDbType.VarChar).Value = txtObservacoes.Text ' Abre a ligação, executa o comando e guarda em "x" o número de registos inseridos connection.Open() Dim x As Integer = command.ExecuteNonQuery() If x < 1 Then End If ' Fecha a ligação e limpa as variáveis connection.Close() connection = Nothing command = Nothing MsgBox(" Registo inserido com sucesso", MsgBoxStyle.Information) Catch ex As Exception MessageBox.Show("A operação efectuada não retomou qualquer resultado.") End Try Me.Close() inicio.Show() End Sub Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'Comboboxes boleanas Dim visivel_rede() As String = {"Não", "Sim"} Dim server() As String = {"Não", "Sim"} Dim ex() As String = {"Não", "Sim"} Dim sql() As String = {"Não", "Sim"} cbxVisivel_Rede.DataSource = visivel_rede cbxServer.DataSource = server cbxEx.DataSource = ex cbxSQL.DataSource = sql End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles btnFotoSeloWindows.Click dlgFicheiro.Title = "Seleccionar Ficheiro" dlgFicheiro.InitialDirectory = CurDir() dlgFicheiro.Filter = "Ficheiros de imagem|*.jpg" If dlgFicheiro.ShowDialog = Windows.Forms.DialogResult.OK Then pbxSeloWindows.Image = New Bitmap(dlgFicheiro.FileName) End If End Sub Private Sub btnFotoSelo_Click(sender As System.Object, e As System.EventArgs) Handles btnFotoSeloOffice.Click dlgFicheiro.Title = "Seleccionar Ficheiro" dlgFicheiro.InitialDirectory = CurDir() dlgFicheiro.Filter = "Ficheiros de imagem|*.jpg" If dlgFicheiro.ShowDialog = Windows.Forms.DialogResult.OK Then pbxSeloOffice.Image = New Bitmap(dlgFicheiro.FileName) End If End Sub Private Sub btnInsereSeloWin_Click(sender As System.Object, e As System.EventArgs) Handles btnInsereSeloWin.Click Dim arqImg As FileStream Dim rImg As StreamReader If Len(dlgFicheiro.FileName) <> 0 Then arqImg = New FileStream(dlgFicheiro.FileName, FileMode.Open, FileAccess.Read, FileShare.Read) rImg = New StreamReader(arqImg) Else MsgBox("Informe um nome para a imagem que deseja incluir na tabela.", MsgBoxStyle.Critical, "Erro") Exit Sub End If stringconnection = "Data Source=.\SQLEXPRESS; Initial Catalog=GestInformatica; Integrated Security=SSPI;" sql = "INSERT INTO foto([fotoWin]) VALUES (@fotoWin)" Dim connection As New SqlConnection(stringconnection) Dim command As New SqlCommand(sql, connection) Try 'declaramos um vetor de bytes para armazenar o conteúdo da imagem a ser salva Dim arqByteArray(arqImg.Length - 1) As Byte arqImg.Read(arqByteArray, 0, arqImg.Length) 'inclui os parâmetros command.Parameters.Add("@fotoWin", SqlDbType.Image, arqImg.Length).Value = arqByteArray 'abre a conexao , executa o comando e fecha a conexao connection.Open() command.ExecuteNonQuery() connection.Close() MsgBox("Imagem incluida com sucesso !", MsgBoxStyle.Information, "OK") Catch ex As Exception MsgBox(ex.ToString, MsgBoxStyle.Critical, "Erro") End Try End Sub Private Sub btnInsereSeloOff_Click(sender As System.Object, e As System.EventArgs) Handles btnInsereSeloOff.Click Dim arqImg As FileStream Dim rImg As StreamReader If Len(dlgFicheiro.FileName) <> 0 Then arqImg = New FileStream(dlgFicheiro.FileName, FileMode.Open, FileAccess.Read, FileShare.Read) rImg = New StreamReader(arqImg) Else MsgBox("Informe um nome para a imagem que deseja incluir na tabela.", MsgBoxStyle.Critical, "Erro") Exit Sub End If stringconnection = "Data Source=.\SQLEXPRESS; Initial Catalog=GestInformatica; Integrated Security=SSPI;" sql = "INSERT INTO foto([fotoOffice]) VALUES (@fotoOffice)" Dim connection As New SqlConnection(stringconnection) Dim command As New SqlCommand(sql, connection) Try 'declaramos um vetor de bytes para armazenar o conteúdo da imagem a ser salva Dim arqByteArray(arqImg.Length - 1) As Byte arqImg.Read(arqByteArray, 0, arqImg.Length) 'inclui os parâmetros command.Parameters.Add("@fotoOffice", SqlDbType.Image, arqImg.Length).Value = arqByteArray 'abre a conexao , executa o comando e fecha a conexao connection.Open() command.ExecuteNonQuery() connection.Close() MsgBox("Imagem incluida com sucesso !", MsgBoxStyle.Information, "OK") Catch ex As Exception MsgBox(ex.ToString, MsgBoxStyle.Critical, "Erro") End Try End Sub Private Sub pbxSeloWindows_Click(sender As System.Object, e As System.EventArgs) Handles pbxSeloWindows.Click 'If pbxSeloWindows.Image = False Then ' btnInsereSeloWin.Visible = True 'Else ' btnInsereSeloWin.Visible = False 'End If End Sub Private Sub btnSair_Click(sender As System.Object, e As System.EventArgs) Handles btnSair.Click End End Sub End Class Link to comment Share on other sites More sharing options...
Lukas S. Posted March 28, 2012 Report Share Posted March 28, 2012 Em que linha se dá o erro ? E o Impossível foi criado por pessoas fracas pra acabar com o sonho das pessoas fortes. Não deixes que acabem com o teu. Sonha , luta , ambiciona e realiza. Se amas , se gostas tu vais conseguir. Cala todas as pessoas que um dia duvidaram de ti e prova que foste mais forte de qualquer outro. Link to comment Share on other sites More sharing options...
Caça Posted March 28, 2012 Report Share Posted March 28, 2012 Fecha todos os forms e faz um rebuild ao teu projecto Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
Blackvelvet Posted March 28, 2012 Author Report Share Posted March 28, 2012 Fecha todos os forms e faz um rebuild ao teu projecto Ja fiz isso e continua na mesma... Em que linha se dá o erro ? não dá erro em linha nenhuma,simplesmente, num dos forms aparece -me o erro e não sei de onde. Segundo li, é um erro de design,mas não sei onde possa estar o erro.Estava tudo bem até ontem. E não,não fiz alterações ao form..... Link to comment Share on other sites More sharing options...
Blackvelvet Posted March 28, 2012 Author Report Share Posted March 28, 2012 Já está resolvido.... Obrigado pela ajuda. Um abraço Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now