I have an F# program that creates an instance of Visual Studio:
let vsTy = Type.GetTypeFromProgID("VisualStudio.DTE.10.0") in
let dte2 = Activator.CreateInstance(vsTy,true) :?> EnvDTE80.DTE2 in
...
That works well; I can probe all kinds of info about the running instance
of Visual Studio.
But I can't determine how to load a solution into the instance of Visual Studio. I've tried dte2.ItemOperations.OpenFile(). I've also tried dte2.ExecuteCommand("File.OpenProject"), which works, but requires the user to select from a file dialog -- I want something that works from code alone.
Here's how to do it:
let soln2 = dte2.Solution :?> EnvDTE80.Solution2 in
let _ = soln2.Open(solutionFile) in
...
Bizarre, because dte2.Solution isn't a solution at all.
Related
When debugging in a Visual Basic Project in Visual Studio 2019, I can't see the values of parameters inside a With-Block when I'm hovering over it with the mouse.
I have Resharper Ultimate installed, but it seems like it doesn't provide a function to show it either.
When using a With-Block the values of ".Name", ".URL", etc.
aren't shown when hovering over them in debug mode:
Private Sub AddCustomer()
Dim theCustomer As New Customer
With theCustomer
.Name = "Coho Vineyard"
.URL = "http://www.cohovineyard.com/"
.City = "Redmond"
End With
With theCustomer.Comments
.Add("First comment.")
.Add("Second comment.")
End With
End Sub
When it is this way, the debugger shows the values just as usual:
Private Sub AddCustomer()
Dim theCustomer As New Customer
theCustomer.Name = "Coho Vineyard"
theCustomer.URL = "http://www.cohovineyard.com/"
theCustomer.City = "Redmond"
theCustomer.Comments.Add("First comment.")
theCustomer.Comments.Add("Second comment.")
End Sub
How can I see the values? Or is there a way to convert the With-Blocks automatically to regular expressions?
Works for me:
Are you sure that you are talking about VB6? Resharper Ultimate sounds more like an extension for Visual Studio.
I can't see the values of parameters inside a With-Block when I'm
hovering over it with the mouse.
Do you use DataTips?
I test it in VS2019 16.1(Community and Professional Edition). In a VB.net console app using your example code, we can use DataTips to monitor variable value in debug mode.
Hover over the thecustomer variable and we can get its details during debugging.If this option not work in your side, try repairing VS or update it to latest VS version.
Hope it helps:)
I have written a console app that uses EnvDTE to process 10 or so solutions and refactor them programmatically - changing references and project structure
var envDteType = Type.GetTypeFromProgID("VisualStudio.DTE.15.0");
var envDte = Activator.CreateInstance(envDteType, true);
var dte2 = (DTE2)envDte;
var solution = (Solution4)dte2.Solution;
solution.Open(filename);
// execute various tasks
solution.Close();
// how to dispose of dte2?
The trick is, when my app finishes there are Visual Studio processes still running presumably opened by EnvDTE. I shutdown my only Visual Studio instance visibly running and they persist.
Is there a way to shutdown those processes that the EnvDTE object spawned?
The following seems to have no effect
dte2.Application.ActiveWindow.Close();
Hans' is correct - dte2.Quit(); does the job
I have few questions regarding development in Visual Studio C# project for AX 2012.
There is a tool that provides Application Explorer from where you can drag any AOT item (Table, Class) in your project.
I dragged CustTable from the Application Explorer into my project and I can see the proxy class generated for it and all the methods that were in the Table are visible but I am interested to fetch all the records like below
select CustTable
So If I create object of the proxy class in Visual Studio how I will get all the records, there is one possibility to write a method in AX and call in the Visual Studio.
Second question is, I have created a class library and added in the C Sharp project of AOT, how I can use in the X++ classes? Is there anyway to call it. Please provide me some links related to it.
You can do one of the following : (assuming you have 2012 R2 by now)
You can use the new Linq provider: For sample code on how to do this, you can see here : http://msdn.microsoft.com/en-us/library/jj677293.aspx
You can use the table proxy as you mention above but this is done by using the find method on the Custtable.
CustTable custtable = new CustTable();
custtable = CustTable.findByCompany(dataAreaId, accountNum);
You could also use the business connector which has been around for a while now. An example of this is found here : http://msdn.microsoft.com/en-us/library/cc197126.aspx (This lets you use things like : axRecord.ExecuteStmt("select * from %1"); )
You can do something like this:
CustTable c = new CustTable();
c.ExecuteStmt("select * from %1");
while (c.Found)
{
MessageBox.Show(c.Name);
c.Next();
}
When you sign into Visual Studio 2013, it caches your profile and credentials in the registry:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\ConnectedUser\IdeUser\Cache
HKEY_CURRENT_USER\Software\Microsoft\VSCommon\12.0\ClientServices\TokenStorage\VisualStudio\IdeUser
When you authenticate with Visual Studio Online using the TFS API, it then copies the credentials to:
HKEY_CURRENT_USER\Software\Microsoft\VSCommon\12.0\ClientServices\TokenStorage\VisualStudio\VssApp
use tfs = new TfsTeamProjectCollection(Uri "https://ctaggart.visualstudio.com/DefaultCollection")
tfs.Authenticate()
How do I use these values in C# or F# using the Visual Studio or TFS APIs?
I've gathered that Vss may mean Visual Studio Services. There is a Microsoft.VisualStudio.Services.Common.CredentialsCacheManager and another in Microsoft.TeamFoundation.Client, but I'm not sure how to use either. It has a ContainCredentials, GetCredentials, and DeleteCredentials, so it looks promising. The GetCredentials returns a TfsCredentialCacheEntry, which has a Credentials property to get the System.Net.NetworkCredential which is exactly what I'm looking for.
I have no idea how to use CredentialsCacheManager, but here is what I tried.
let ccm = Microsoft.TeamFoundation.Client.CredentialsCacheManager(#"Software\Microsoft\VSCommon\12.0\ClientServices\TokenStorage\VisualStudio", false)
ccm.ContainsCredentials("IdeUser", Uri "ideuser:https://app.vssps.visualstudio.com:vssuser:federated")
Using Process Monitor, it shows that CredentialsCacheManager is either not what I'm looking for or I don't know how to use it:
I figured it out. The Microsoft.TeamFoundation.Client.TfsClientCredentialStorage has what I'm looking for. I put all the example code in a F# script as a gist. I'll copy it here as well:
#r "Microsoft.TeamFoundation.Client"
#r "Microsoft.VisualStudio.Services.Common"
#r "System.Net.Http"
open System
open Microsoft.TeamFoundation.Client
// retrieve VssToken
// for the logged in user "IdeUser"
let vssTokenIdeUser = TfsClientCredentialStorage.RetrieveConnectedUserToken()
let tokenStorage = Microsoft.VisualStudio.Services.Common.TokenStorage.VssTokenStorageFactory.GetTokenStorageNamespace "VisualStudio"
let vssTokens = tokenStorage.RetrieveAll "VssApp" |> Array.ofSeq
for t in vssTokens do
printfn "%s %s %s %s" t.Resource t.Type (t.GetProperty "UserId") (t.GetProperty "UserName")
// create a TfsClientCredentials by retrieving an IssuedToken
let ccs = TfsClientCredentialStorage()
let ct = ccs.RetrieveToken(Uri "https://ctaggart.visualstudio.com", Microsoft.VisualStudio.Services.Common.VssCredentialsType.Federated) :?> CookieToken
let cc = CookieCredential(false, ct)
let tcc = TfsClientCredentials cc
// use the TfsClientCredentials to authenticate with
let tfs = new TfsTeamProjectCollection(Uri "https://ctaggart.visualstudio.com/DefaultCollection", tcc)
tfs.Authenticate()
Maybe this is a very simple problem, but I just can't figure it out. Is there any way to navigate to a certain folder in MS Visual SourceSafe from an external application?
Maybe some sort of command line parameter? (of course that would only work if VSS is closed). Or is there a solution that would also work if VSS is already opened? (COM?)
Thanks!
Here is VBS sample code to start programmatically control VSS:
const SS_INI_PATH = "с:\db\vss\srcsafe.ini"
const SS_LOGIN = "login"
const SS_PASSWORD = "password"
set obj = CreateObject("SourceSafe")
obj.Open SS_INI_PATH, SS_LOGIN, SS_PASSWORD
set objPrj = obj.VSSItem("$/project1")
' call below any objPrj methods
Help on object interfaces you can find here:
http://msdn.microsoft.com/en-US/library/microsoft.visualstudio.sourcesafe.interop(v=vs.80).aspx