2

I'm using a vb6 dll, running on development works perfectly, when deployed (published in the same development machine) throws this error Object reference not set to an instance of an object

Like i said, it is the same machine, so i dont know what can be wrong. I already set defaultapppool to enable 32 bits apps, the platform in debug configuration is x86 also.

I tried to copy the dll file to the bin folder of the project published folder, and nothing happened.

The error does get fired when the function CalcularNecesidadPedido is called.

Dim calc As New WinBlindCalculoProd.WBCalculoProd
        Try

            If calc.CalcularNecesidadPedido(cnnpedidos, Distribuidor.SelectedItem.Value.ToString, argument(0)) Then

It doesnt even trigger the catch, just throw the error message from above.

Thanks in advance.

UPDATE

The problem seems to be on this insert of the vb6 dll:

strSQL = "Insert Into NecessidadePedido (Cliente,PedidoVenda,ItemVenda,Sequencia,DataExplosion," & _
                " Uso,TipoComponente,Setor,Almoxarifado,TipoDocumento, " & _
                " Componente,CorComponente,Manter_Estoque,Dimensoes,CompraEspecifica,TipoEstoque," & _
                " Altura,Largura,Comprimento,OrdemMontagem,QtdNecessaria,Consumo) Values('" & Cliente & "','" & Pedido & "'," & intItem & "," & intSequencia & _
                "," & PrepDate(Now(), CNN, True) & _
                ",'" & strUso & "','" & strTipoComponente & "','" & strSetor & "','" & strAlmoxarifado & "','" & strTipoDocumento & "','" & _
                strComponente & "','" & strCor & "'," & Cbit(blnManter_Estoque) & "," & intDimensoes & "," & Cbit(blnCompraEspecifica) & ",'" & sTipoEstoque & _
                "'," & sngAltura & "," & sngLargura & "," & sngComprimento & "," & Cbit(blnOrdemMontagem) & "," & sngQuantidade & "," & sngConsumo & ")"

                CNN.Execute strSQL

I extract the strSQL string from development and deployment, this how they look like:

Dev: Insert Into NecessidadePedido (Cliente,PedidoVenda,ItemVenda,Sequencia,DataExplosion, Uso,TipoComponente,Setor,Almoxarifado,TipoDocumento, Componente,CorComponente,Manter_Estoque,Dimensoes,CompraEspecifica,TipoEstoque, Altura,Largura,Comprimento,OrdemMontagem,QtdNecessaria,Consumo) Values('1','16784',1,11,{ts '2019-03-21 15:44:14'},'000','99','0001','01','PV','010216','000',1,1,0,'0',0,0,1250,1,1,1.25)

Dep: Insert Into NecessidadePedido (Cliente,PedidoVenda,ItemVenda,Sequencia,DataExplosion, Uso,TipoComponente,Setor,Almoxarifado,TipoDocumento, Componente,CorComponente,Manter_Estoque,Dimensoes,CompraEspecifica,TipoEstoque, Altura,Largura,Comprimento,OrdemMontagem,QtdNecessaria,Consumo) Values('1','16784',1,11,{ts '2019-03-21 15:41:27'},'000','99','0001','01','PV','010216','000',1,1,0,'0',0,0,1250,1,1,1,25)

So the problem seems to be that consumo value, on deplyoment throws comma instead of dot for decimals. When i comment that line, it works on deployment.

I already tried to change the region settings of this pc, it didn't work. Any ideas? I don't want to modify that dll because it is used on other projects.

Harry
  • 70
  • 1
  • 8
  • 3
    That answer has little to do with calling unmanaged vb6 dll's. Of course the poster gets a null object, because the unmanaged vb6 dll call is not working, not because some object not initialized. If you take that assuming, then we would NEVER have to answer a question on SO. I mean, I flip the switch and the light don't go on. You can't just post to a answer that says the light bulb not getting electricity as a valid answer. We have to suggest a broken wire, a tripped fuse, light bulb not screwed in all the way. Telling everyone the bulb is not getting electric (or null object) is not a answer – Albert D. Kallal Mar 21 '19 at 03:36
  • What happens when you put a breakpoint on that line. Does it reach the breakpoint? – Chris Dunaway Mar 21 '19 at 13:47
  • If a put a breakpoint on that line, it means that i'm running it on development on visual studio, it works perfectly on development, the problem happens when project is deployed. – Harry Mar 21 '19 at 14:18
  • I suspect a dependency of the VB6 DLL is missing. – R.J. Dunnill Mar 21 '19 at 16:22
  • I was thinking the same, but why works on development? i'm using the same machine. – Harry Mar 21 '19 at 16:59
  • Filepaths? Debug versus release? – R.J. Dunnill Mar 21 '19 at 17:30
  • Nope, the object creates without problem. I think i'll have to find the source code of that vb6 dll. – Harry Mar 21 '19 at 20:44
  • You want to set the Application Locale, or the Users Locale, not the PC region. – david Mar 22 '19 at 09:46
  • 1
    Are you running your dev environment under administrator privileges? That VB6 code and modules assume unfettered access to now-sensitive folders and Registry settings can be the source of difficult-to-trace runtime bugs. – R.J. Dunnill Mar 22 '19 at 16:04
  • Since i added the reference to that dll, i have to open visual studio as administrator, otherwise i get this error `Cannot register assembly 'absolute\path\to\NameOf.dll' access denied. Please make sure you're running the application as administrator.` – Harry Mar 22 '19 at 16:37
  • 1
    Given that, I suspect your problem is that the VB6 DLL lacks the privileges for certain operations it must perform. I have come across this issue in the recent past myself. – R.J. Dunnill Mar 22 '19 at 16:43
  • Is there a way to reopen this question? I would like to share the workaround i did, i have to edit the dll on that string. However the duplicate link didnt help at all. Thanks to everyone that helped. – Harry Mar 22 '19 at 17:46
  • It's easier to create a new question, and answer it yourself. – R.J. Dunnill Mar 22 '19 at 18:02

0 Answers0