Migrating videosoft vsindextab from VB6 to VB.NET - vb.net

I have a VB6 project I need to migrate to VB.NET.
I tryied with both the migrating tool of VB.NET express 2005 and 2008 with the same result.
When I try to open a form in designer mode containing a videosoft's vsindextab component in the resulting project of the migration, I receive the following error:
Warning 1 Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME)) C:\gestionbtdotnet\FormBT.Designer.vb 261 0
The line in error is in the designer.vb file and is the following:
CType(Me.vsIndexTab1, System.ComponentModel.ISupportInitialize).BeginInit()
(The vsIndexTab being a vsOcx6lib.vsindextab object)
I searched all over the web about it but couldn't find anything.
I tryied using a different .NET Framework version, I tryied copying the ocx file (vsocx6.ocx) to every possible places, I tryied simply erasing the line in error.
No luck.
Can anyone help me?

You can only migrate code. Projects that depend on third-party components that are binary-only and not .Net compatible (like the vsindextab component used here) will not migrate. Here are your options:
Check with the original vendor for a .Net version of the same component.
Find another .Net-compatible replacement for the component, and re-write code to use the new replacement.
Rewrite existing code to avoid using the component anywhere at design time. Factor that section out to it's own library that you can invoke at run-time only. Then build custom dllimport code to use that library at run time.
Write your own replacement for the component, relying on existing .Net widgets.

Related

COMExcepton occurred trying to create a new instance of Microsoft.Office.Interop.Word.Application

I am trying to create a word document using visual basic. I have found that this can be done using the Microsoft.Office.Interop.Word objects.
I have found some tutorials online (https://support.microsoft.com/en-us/kb/316384) about how to create a word document programmatically.
I have created a simple windows form application. When a button is clicked the word document will be created. I made sure to add the reference to Microsoft.Office.Interop.Word in my application.
My problem is that an error keeps getting thrown at this point:
app = New Microsoft.Office.Interop.Word.Application
The error is:
COMException occurred
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: Retrieving the COM class factory for component with CLSID (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: ox80080005 (COE_SERVER EXEC FAILURE)).
I have read that the following needs to be done, so I have made sure that word 2013 is installed on my machine and I have set the target CPU to x64 inside the application's properties.
If anyone has any insight to what I am missing or if I am doing something wrong I would appreciate the help.
Update:
I have tested my code on another machine and it works. So the source of this error is not the code.
Update: Pt. 2
I've been doing some more research (http://www.microsoft.com/technet/support/ee/transform.aspx?ProdName=Windows+Operating+System&ProdVer=5.2&EvtID=10010&EvtSrc=DCOM&LCID=1033) and I believe I may be getting closer to the source of the problem. I've gone into the registry and it seems that the local server it is failing to communicate with is pointing to WINWORD.exe which makes sense. What does not make sense is that it is looking for the wrong WINWORD.exe. I am going to try and fix this so it is pointing to the WINWORD.exe for Word 2013 instead of Word 2010.
Solution
What ended up fixing my problem was preforming a quick repair on office. I went to control panel, programs and features, selected office, pressed the change button, and selected quick repair. Do not know what caused things to get messed up, but this did fix my problem.
Where do you run the code? Is it a Windows service or ASP.NET application?
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.
You may find existing threads with the same issue described:
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID
Office Automation in .NET - COMException 80080005
Word Automation with ASP.NET
Finally, if all the mentioned information is not relevant to your case I'd suggest repairing Office. It looks like something is wrong with its windows registry keys.

Could not load type 'System.Data.Entity.Core.Mapping.EntityContainerMapping'

When I debug the following code, I receive the message "System.TypeLoadException was caught" when I perform the Delete().
Using db As New ScholarshipEntities
db.ApplicationHistories.Where(Function(h) h.HistoryTypeId = 0).Delete()
db.SaveChanges()
End Using
I am using EF 6.1 in Visual Studio 2013. I also have the EntityFramework.Extended library installed.
I have no trouble querying results. I thought the bug might occur when the Where method has no results, but that is not the case. I also have no problem adding new models (.edmx), which was a problem some people with this exception had.
I just recently upgraded to EF 6.1 and installed the Extended library. This is my first time using one of the extended methods. I've un-installed and re-installed the nuget packages with no success.
IntelliTrace shows the following exceptions from the Delete() call (in order):
'EntityFramework.Reflection.DynamicProxy' does not contain a definition for 'InternalQuery'
Cannot implicitly convert type 'EntityFramework.Reflection.DynamicProxy' to 'System.Data.Entity.Core.Objects.ObjectQuery<Scholarship.ApplicationHistory>'
Could not load type 'System.Data.Entity.Core.Mapping.EntityContainerMapping'
I've added an issue on the Extended library's github.
Update
I've reinstalled EF and the EF.Extended library with no luck. I am able to use RemoveRange in its place. I am able to create a new project, install the packages, add a model mapped to the same database, and successfully use Delete. Obviously, the problem is in my current solution.
In my solution, I have an ASP.NET project and a regular library project. In the ASP project, a page's code behind calls a method in the library RemoveHistory. The library contains classes for the business logic and data access. Both classes implement interfaces. The actual Delete occurs in the data access class. My model also resides in this library project.
I may be able to create a completely new project and bring everything over, but that will take quite some time. Even if I did, I want to understand why it doesn't work in the first place, so that I don't have to repeat this process.
If you want to delete certain rows do it like that:
Using db As New ScholarshipEntities
db.ApplicationHistories.RemoveRange(db.ApplicationHistories.Where(Function(h) h.HistoryTypeId = 0))
db.SaveChanges()
End Using
If you want to remove single entity do it like that:
Using db As New ScholarshipEntities
db.ApplicationHistories.Remove(db.ApplicationHistories.Single(Function(h) h.HistoryTypeId = 0))
db.SaveChanges()
End Using
I "solved" the issue some time ago. I'll eventually go back to try and reproduce the problem to confirm my suspicions.
There were multiple versions of Entity Framework installed in the solution. This didn't appear to affect basic EF functionality, though I'm sure it did in some subtle, potentially buggy fashion.
Every time the solution was opened, NuGet would state that it couldn't complete uninstallation. Uninstalling and restoring via NuGet was unsuccessful, and the packages had to be deleted manually. Once completely removed, I installed the packages again. This resolved the issue.
I wish I could give a more technical answer, though the basic reason was forgetting to look closer at the packages folder and configuration.

System.InvalidOperationException is scaring me

I recently reset my whole laptop. After the reset, I installed all of my programmes, including Visual Studio 2013 (I had 2012 on my last build). I then dumped my projects into the projects folder of 2013 and...I COULDN'T RUN MY PROJECT!!! I can view the code and the designer but I can't run it.
The error is from Application.Designer.vb and it is a "System.InvalidOperationException" error. Under additional information, it says "An error occured creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object. Highlighted is Me.MainForm = Global.MyApplicationName.Form1
I have checked msdn for answers about System.InvalidOperationException but haven't found any fixes that work.
I really don't know what to do and don't want to lose my application as I've spent a fair bit of time on it.
I have 2 suggestions to try
Open Application.Designer.vb and just delete the word Global.
Exclude (not delete) the mainform (Form1, apparently) from the project. Save it. Then include it again and go to Project Properties and make it the startup form again.
I've had similar issues (without the exception) when reorganizing pieces of large solutions into other namespaces. Often, I need to drill into the designers to change a ref to get it to run and it is usually removing 'Global' and/or adding the new Namespace ref. In your case, it sounds like a similar reference in the project did not get updated from 2012.
If that is the case, the second way should get VS to write back all the files in a manner that it likes.

Entity Framework 5 entity in separate dll

I have a DLL that is a logging component that we use in many different projects. This logging component is designed to be entirely self-contained, and thus it must have its database connection string internal to it. In this project, it is completely unacceptable to require that its connection string be copied to the app.config of any project that uses it.
This has been working great for years, but now we have found that mixing its older ADO tech with new apps that use EF results in horrible performance when the logging is being done. For example, adding a single log entry when the application starts results in a > 30 second delay before the app opens.
So to combat this, I have re-written this component to use EF.
The problem is under the current EF (version 4.4 since we are targeting .Net Framework 4.0) does not offer a constructor to DBContext that allows you to specify the entire connection string. The code attempts to change the Database.Connection.ConnectionString, but the DBContext object insists on looking in the App.Config for the connection string even though we are giving it a new one.
I must get around this behavior.

Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute is not defined?

I'm attempting to create a new project similar to the SDK project basicoperations for Dynamics CRM 2011. I am using the myorganizationcrmsdktypes.vb file included with the SDK helper code, but when I attempt to build the code I get tons of errors in myorganizationcrmsdktypes.vb and I'm not sure why. The errors look like this:
Type 'Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute' is not defined.
The code works fine when run in the original project, just not in mine?
Add a reference to: Microsoft.Xrm.Sdk (/sdk/bin/microsoft.xrm.sdk.dll)
Also add another reference to: System.Runtime.Serialization
Additionally in your project settings - try clearing the Root namespace
Have you tried your code on a different machine? This is less of a CRM issue and more of a .net issue. If your vb project has a reference to the Microsoft.Xrm.Sdk dll but yet your code can't find the classes within it, I'm almost wondering if something is corrupt.
I'd try recreating the solution / project. I'd also try doing a ctrl-. (control period) to see if VS can resolve it for you...