'IDTExtensibility2' is ambiguous in the namespace 'Extensibility' - vb.net

I am trying to build a COM Add-In and I get the errors:
'IDTExtensibility2' is ambiguous in the namespace 'Extensibility'.
'ext_DisconnectMode' is ambiguous in the namespace 'Extensibility'.
'ext_ConnectMode' is ambiguous in the namespace 'Extensibility'.
My imports are as follows:
Imports Extensibility
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Core
I used the shared add-in wizard in VS 2010 and I am using VB.NET.
The codes that have errors are anything that contains:
Extensibility.IDTExtensibility2
I couldn't find this anywhere and I figured the wizard would work without errors. Any thoughts? Thank you.

Check whether one of the Microsoft.* namespaces already imports the Extensibility namespace.
If not, there is possibly an upper-/lowercase ambiguity, try whether you can access the class in C# or through reflection.
If it still does not works, there probably goes something wrong during interop proxy generation but then it get's complicated, you have to use the tlbimp.exe tool and toy around with its options.

Related

Should I use Imports or not?

To avoid having unnecessary code in my program, I am wondering which choice should I use:
Use the statement like this Imports System.Threading and then use the code Dim myTimer As Timer
Do not use the statement Imports System.Threading at all, but use a full declaration like this: Dim myTimer As System.Threading.Timer
Both choices give the desired result, but I want to avoid adding all extra code from System.Threading that I do not need.
The question came to my mind when I saw the answer to the question here: How to correctly terminate an application?
Here the user wrote …Threading.Timer(…, but didn't use Threading on the Timeout.Infinite.
Since I am using System.Threading in only one point in my code, which choice would be better?
Thank you.
You don't "add all extra code from System.Threading" if you use Imports. You just tell the compiler that you want to use that namespace, so you avoid always using the fully qualified namespace.
As a rule of thumb: use Imports whenever you need it at least once. Fully qualified namespaces don't make your code more readable, it's also harder to see what you use in this class if you omit the Imports.
You can use Code Cleanup On Save to ensure that unused Imports are removed from your code when you save the file. But again, this is just removing redundant code, it will not improve performance or whatever.
Another option (that I favour) is to use Add Reference and/or Import Namespace on the project's References tab rather than use Imports or fully-qualified names. Unless it's just a single instance or two, in which case I'll fully-qualify to tell me that I don't use this reference/namespace a lot in my code. It's just a preference. (Or should I say a "reference preference"? Perhaps not.)

DocumentFormat for OpenXML

I'm trying to create an Excel file to save using OpenXML and I've found some guidelines on Microsoft website, talking about declaration of OpenXML through importing modules. I added at the beginning of the code:
Imports DocumentFormat.OpenXml
Imports DocumentFormat.OpenXml.Spreadsheet
Imports DocumentFormat.OpenXml.Packaging
I'm having back three warnings, each per line: BC40056 Namespace or type specified in the Imports 'DocumentFormat.OpenXml' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. Besides, I'm also having issues while compiling the code itself, because every time I recall DocumentFormat, I receive back an error about "not declared" variable. Which could be the problem? Thanks in advance all are gonna answer me.

VB.Net: LUIS Dialog context.Wait(MessageReceived) issue

As a challenge to myself, I've created a Visual Basic app that uses the Microsoft Bot Framework and LUIS API. To my own amusement, I've largely gotten it working .. almost.
After getting over some C# to VB hurdles, there's one I can't get over, which is stopping my app from keeping the conversation stack from functioning properly (it bails out after one interaction).
Specifically, I have the following code fragment inside of my dialog code:
Imports System
Imports System.Threading.Tasks
Imports Microsoft.Bot.Builder.Dialogs
Imports Microsoft.Bot.Builder.Luis
Imports Microsoft.Bot.Builder.Luis.Models
<LuisModel(“xxxxxxxxxxxxxxxxxxxxxxxxxx”, "xxxxxxxxxxxxxxxxxxxxxxxxxx")>
<Serializable>
Public Class MyLuisDialog
Inherits LuisDialog(Of Object)
<LuisIntent("None")>
Public Async Function NoneIntent(context As IDialogContext, result As LuisResult) As Task
Await context.PostAsync(“this is boring chat ..“)
context.Wait(MessageReceived)
End Function
but I cannot interpret the context.wait(MessageReceived) from C# into VB.
The compiler wants to do:
context.wait(MessageReceived(context,????????))
but I cannot figure out what to put in for ?????.
Irritatingly, the C# version just works in the form context.wait(MessageReceived).
Assistance as to what syntax/code should be used when using VB gratefully accepted :)
Try with context.Wait(AddressOf MessageReceived)

DomainContext not being generated in RIA Service for Silverlight 4

I have added my domain service but when I build my web project the DomainContext never gets generated. I am new to RIA Services and trying to learn but I am really stuck.
Here is my Domain Service
Option Compare Binary
Option Infer On
Option Strict On
Option Explicit On
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.ComponentModel.DataAnnotations
Imports System.Linq
Imports System.ServiceModel.DomainServices.Hosting
Imports System.ServiceModel.DomainServices.Server
Imports Wellness.BL
Imports System.Collections.ObjectModel
'TODO: Create methods containing your application logic.
<EnableClientAccess()> _
Public Class EventScheduleService
Inherits DomainService
Public Function GetEventSchedule(ByVal ScheduleYear As Integer) As IEnumerable(Of Models.EventSchedule)
Return DataServices.EventSchedulesDataService.GetEventSchedule(ScheduleYear)
End Function
End Class
Maybe Models.EventSchedule, the class that is the base for your IEnumerable, is in a library that you have referenced in the Web project but can not be referenced in the client as it is not a Silverlight library?
I think that would prevent the EventScheduleDataContext from being generated in the client.
A simple test would be to change base of the IEnumerable to a class that lives in the Web project.
I had this problem also. My problem was that Visual Studio was set to Release mode. Setting it to Debug mode solved it.

Working of "imports namespace"

I knew from here that we have to do the explicit imports for child namespace because imports will not include the child namespace.
But my question is that if I do "imports System" whether it will include all the classes/methods inside that namespace in the IL/native code or only referred ( used inside the application) will be included in the IL/native code.
Importing a namespace doesn't mean that anything is included in the code. It only means that the compiler recognises identifiers from that namespace.
The references in your project are what really decides which libraries the application is using. Still, the libraries are loaded when needed, they are not included in your executable file.