I am converting a Visual Studio 2010 macro to work in an addin. I am using VB. How do I correct the line below:
Dim win As Window = DTE.ActiveWindow
which gives this error:
Error 3 Reference to a non-shared member requires an object
reference. C:\Users\Frank\documents\visual studio
2010\Projects\MyAddin2\MyAddin2\Module1.vb 28
The DTE is passed via the Application parameter in IDTExtensibility2.OnConnection. This method is called when the AddIn is initialized by Visual Studio.
The AddIn project wizard should have generated some code that casts the Application parameter to a field of type DTE2. Use that field to access the ActiveWindow property.
Related
I have a VS 2013 Express system that uses an Access db. After populating the db with values, I open a report object created in Access. This all worked perfectly approximately 1 year ago. Now, in development or production, trying to open the report throws an error.
The code behind the form is:
Imports Access = Microsoft.Office.Interop.Access
Public Class frmReports
Public db_path As String
Dim oAccess As Access.application
And the code behind the button that opens the report is:
Private Sub btnSumByPlan_Click(sender As Object, e As EventArgs) Handles btnSumByPlan.Click
oAccess = CreateObject("Access.Application")
oAccess.visible = True
oAccess.opencurrentdatabase(db_path)
oAccess.docmd.openreport(ReportName:="rptSumByPlan", view:=Access.AcView.acViewPreview)
End Sub
However the code fails on the CreateObject line with the following error:
An unhandled exception of type 'System.Exception' occurred in Microsoft.VisualBasic.dll.
Additional information: Cannot create ActiveX component.
I have the following COM references selected:
Microsoft Access 12.0 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Microsoft Office 12.0 Object Library
Microsoft Visual Basic for Applications Extensibility 5.3
I have tried selecting different versions of the Access, Office and ActiveX libraries but still get the same error.
I'm not positive, but I think I was running Office 2010 a year ago and now Office 2013.
Can you tell me what I'm doing wrong?
Thanks in advance.
Unity version 2.1.505.0 in both WPF projects. One in 2010 & other in 2012.
In 2010 fine but 2012 I get Error "The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' cannot be used with type arguments"???
return this.Container.Resolve<Shell>();
Needed to add using for the Unity namespace as well as Prism.UnityExtensions. Answer was here on StackOverflow.
Whenever i try to record an action in a coded UI test , the action is recorded but as soon as i try to generate the code an error pops up saying
"Object reference not set to an instance of an object"
The recording was working fine till yesterday so there is no issue of visual studio version or service pack. I am using visual studio 2010 ultimate.
I'm working on a Classic ASP (with VB Script) project where I'm instantiating an object from an ActiveX control like so:
Dim objHelper
Set objHelper = Server.CreateObject("HelperLib.HelperObj")
Visual Studio 2005 provides intellisense for the first "layer" of properties and methods, but it can't seem to see properties and methods that are members of the main objects. For example:
objHelper. 'Properties and methods show up after the period '
objHelper.FirstProperty. 'No properties and methods are shown after the period'
Is there a way to "help" Visual Studio in some way to see these object types so that I can work in a more strongly-typed environment?
Unfortunately, 2005 does not do this. 2008 does a very good job of it, however. Once you install sp1, that is.
Visual studio type library
I'm trying from Delphi to open up Visual Studio (for editing SSRS reports), and load up a particular projectitem from a solution file I have autogenerated.
I have imported the visual studio type library, and can create the object,
and drill through the solution until I have the right ProjectItem
objDTE := CreateOleObject('VisualStudio.DTE') as DTE;
However I am now at the point where I have the ProjectItem, and want to
do the following
_ProjectItem.Open(vsViewKindDesigner);
Unfortunately vsViewKindDesigner is some sort of constant that I can't
find a type library for, and it must relate to a particular Guid underneath.
Any ideas where I can import this type library from in order to use this constant in the ProjectItem.Open method?
ProjectItem = interface(IDispatch)
['{0B48100A-473E-433C-AB8F-66B9739AB620}']
.... etc
function Open(const ViewKind: WideString): Window; safecall;
.... etc
Thanks!
vsViewKindDesigner = {7651A702-06E5-11D1-8EBD-00A0C90F26EA} (Designer view).
source: http://msdn.microsoft.com/en-us/library/aa301250(VS.71).aspx
Have you looked for that constant in the Visual Studio SDK? MSDN? Google?
See http://social.msdn.microsoft.com/Search/en-US/?Query=vsViewKindDesigner.