How do I use GetExtensibilityService when building a Visual Studio Extension? - visual-studio

I am working on a Visual Studio Extension. I am trying to get the ID of a code review request after it has been created/saved. I have added my own ITeamExplorerSection to the RequestCodeReview page. It makes sense to me that In my implementation of the SaveContext method of my section that I should be able to call the GetExtensibilityService on the page and retrieve the "CodeReviewId". I have several issues with this, the most important of which are: What object type am I trying to retrieve? and second is it available in the SaveContext Method. (or is this even the right approach)

Related

Make IntelliSense work in Visual Studio

I am using Visual Studio 2015, and I want to add https://appsforoffice.microsoft.com/lib/1/hosted/office.js as an IntelliSense reference. So I did the following:
But the IntelliSense still does not work:
Could anyone help?
Getting the basics of JavaScript IntelliSense working is pretty straightforward – all you need to do is, in your JavaScript file, have a triple slash reference to the CDN location, as follows:
/// <reference path="
https://appsforoffice.microsoft.com/lib/1/hosted/office.js" />
In projects created with the Office Add ins template, the reference is already built in, in the Scripts/_reference.js file. The Scripts/_references.js file is a special file that acts as a "global" JS reference for the project, so that you don't need to include the /// <reference path="..." /> on every file. For more information on the _references.js file, see this excellent blog post by Mads Kristensen, creator of the “Visual Studio Web Essentials” extension: http://madskristensen.net/post/the-story-behind-_referencesjs.
Note that the above location is for the “prod” version of the CDN. For the beta endpoint, use "https://appsforoffice.microsoft.com/lib/beta/hosted/office.js", and for a local installation of Office.js point to the Office.js file (typically under "Scripts/Office/1/office.js).
TIP: Every once in a while, I've come across cases when the IntelliSense file appears stale. For example, while I know for a fact that the Excel Range object contains a “.merge()” method, IntelliSense was refusing to show it to me one day.
In these cases, you can refresh the JavaScript references by via the menu, by going to Edit -> IntelliSense -> Refresh Remote References, or via the VS Quick Launch box.

Accessing resources XML from another library project in Xamarin.Android

I am trying to create a Xamarin.Android Component to send to the Xamarin Component Store, and I need to bundle my Colors.xml with it, so it is accessible to everyone using my component. I am setting the build action for the Colors.xml tp "AndroidResource".
So I created an Android sample application, when I add a reference to my library project's dll, I am able to use the colors defined, my project compiles and it runs, but I get no intellisense on Xamarin Studio. So that would be a bad thing for anyone using my library, as they would not be able to even see that the colors are available to use. You can see in this picture the colors defined are not available in the suggestions box.
If I add the Colors.xml directly into my project, I get Intellisense support, like this:
Is there a way to achieve the same result above when adding just the dll reference? Did I do something wrong or Xamarin.Android/Xamarin Studio doesn't support this kind of scenario?
EDIT: To be clear, I know this is a problem with Intellisense not being able to pick up the values, but is there anything I can do to make it work?

References for MVC extension methods differ between vbhtml and cshtml files?

I am converting the login views of an application from vbhtml to cshtml. In the vbhtml files the original developer calls an Html.LabelWithAttributesFor extension method. When I write the same line of code in the new cshtml file the extension method isn't available via Intellisense and fails to compile. Are references not shared between vbhtml and cshtml files in a project?
Wanted to circle back and close this question with the "answer". In the end, what seems to have knocked something loose was when we removed the vbhtml pages from the solution. All use of the Extensions had been removed prior to our removing the vbhtml pages and other developers had worked on the solution in the interim making other changes. Fast forward a few months to another developer needing the extensions. He added a reference to the project with the extension methods and used them on a new cshtml page, which worked fine. So, the problem is solved but I still have no idea what caused the problem in the first place and I have been unable to reproduce it.

Running ASP.NET on Mono Resource Access Errors

Summary of Solutons: The core issue was that I had my resx files in subfolders within App_LocalResources and App_GlobalResources. Separating things into folders is fine on .NET but Mono only looks at the files in those folders ignoring any sub folders.
Issue #2 works only at runtime. In other words the Resources namespace can be used in the aspx or in code in a script block in the page but not in the code behind. It seems that I've never used the Resources namespace in the code-behind proper so all 3 of my issues are solved.
I have an ASP.NET application I was previously working on on .NET on a PC and am trying to move over to a Mac to develop using Mono and MonoDevelop. The application utilizes the App_GlobalResources and App_LocalResources folders. The application worked on .NET but does not function properly on Mono as I will outline. The version information is below:
OS: Mac OS 10.8.2
Mono: 2.10.9
ASP.NET: 4.0.30319.1
MonoDevelop: 3.0.5
I've tagged this with MonoDevelop because I'm not sure what server is being used and whether it is a part of MonoDevelop or Mono itself or is separate. I'm not familiar enough yet with Mono and it's parts...
The issues I'm having revolve around accessing resources and I'm having various related issues which I'll outline below:
Issue 1: meta:resourcekey doesn't work and "a resource object was not found at the specified virtualPath." error
I have App_LocalResources folders and resx files for each page at the root of the application as well as in sub-folders where page localization is required. Elements on the page that have a meta:resourcekey attribute do not have the relevant property assigned the value in the resx file.
So for example I have: /Site/Home.aspx with a /Site/App_LocalResources/Home folder which contains home.aspx.resx and related translations
N.B. as I was writing this I realised the names don't match up with regards the files case, but that is not the issue, I've tested with another page in the same folder and it doesn't render out the resource values.
The page in question has no code behind.
A different page in the root of the application called PageNotFound.aspx has related resx files in /App_LocalResources/PageNotFound/PageNotFound.aspx.resx
This page content is basically as follows (if I remove both the page renders)
<h2><asp:Literal runat="server" meta:resourcekey="PageNotFound" /></h2>
<% string message = GetLocalResourceObject("Sorry.Template").ToString(); %>
I get the same error whether I remove the first or the second of these lines. The error starts:
System.Resources.MissingManifestResourceException: A resource object was not
found at the specified virtualPath at
System.Web.Compilation.DefaultResourceProvider.GetLocalResourcesAssembly
If I remove the first line is actually builds and tries to render the page but crashes giving the above error.
If I remove the second line I get the error as well but it is while the page is being parsed and the runtime is trying to build the page class.
So for one page is seems build and run with meta:resourcekey attributes but isn't binding the resource value to the properties of the underlying controls, on another page it seems to crash trying to access the resources. The odd thing is the page that crashes is a very simple page without a master page and it basically only has the above content, the other page is quite complex with a master page and it renders (i.e. no parser error) but without the resourcekey values assigned....
The only differences that I can see are that one page is in the root directory and no master page, the other is in a sub folder and has a master page? Go figure! Any ideas?
Issue 2: Resources namespace doesn't exist
If I access a page that uses the 'Resources' namespaces that is available in .NET, I get a runtime compilation error, as in the app builds when compiled, but as the page is parsed and compiled it causes a (runtime) exception...
Compilation Error: CS0103: The name 'Resources' does not exist in the current context
The code would be in the code behind: (EDIT: The following line I think, was me testing, my code never uses this namespace in a code behind (compile time) class. Once the global resources functioned then the namespaces worked at runtime, but not in scenarios where the namespace needs to be verified at compile time as outlined in the summary at the top of the question)
msg.Subject = Resources.EmailResources.Request_SubjectLine
or in a script block in the aspx itself i.e.
<%= Resources.EmailResources.Request_SubjectLine %>
Neither of these types of access to the Resources namespace work. Why does this not work in Mono. Does the Mono framework not generate this stuff for us like .NET does? (I'm fairly sure this namespace hierarchy is generated by the ASP.NET framework on .NET and therefore wonder if this just has not been implemented in Mono?)
Issue 3: GetGlobalResourceObject(...) Call Returns Null
In the code-behind I have calls to GetGlobalResourceObject() which works on .NET, but when I run it on Mono my code is throwing an exception. For example:
hlContact.Text = GetGlobalResourceObject("CommonResources", "Contact").ToString();
My folder structures is:
App_GlobalResources > CommonResources > CommonResources.resx and the designer file (CommonResources.Designer.cs) is there.
The resx files are all marked with build action of "EmbeddedResource", "Do not copy" use the Custom Tool "GlobalResourceProxyGenerator" and have a resource ID that makes sense for each file. (i.e. .App_GlobalResources.CommonResources)
The issue is that GetGlobalResourceObject() returns null... It's not finding the CommonResources resource....
Note that Mono is constructing '*.resource' files in the folder with the resx files.
Issue #1
Apparently mono doesn't search subdirectories for resources, that is you must keep them directly in App_LocalResources or App_GlobalResources. See the relevant part in the mono source code (line 134). If searching subdirectories is an official feature, then this is a bug, and can be easily fixed by changing the aforementioned line.
Issue #2
Works fine here (on linux).
Issue #3
I don't know how exactly you are embedding the resources, a small test project would help. For the App_GlobalResources the framework compiles them at runtime and then GetGlobalResourceObject works fine too.

How to deploy aspdotnetstorefront source code changes?

I'm implementing an AspDotNetStorefront (ASPDNSF) site for a client, they've purchased the source code and I'm just trying to do something simple like add an ID for CSS styling to the product images.
I've gone into the source and made the AspDotNetStorefrontCore.XSLTExtensionBase.LookupProductImage() method just return the string "TEST" expecting any product image to be replaced with "TEST", compiled the solution using Visual Studio's build. It builds successfully and the DLLs in the /web/bin directory now reflect modified dates the same as my build time, but the rendered page does not reflect my changes. I've reset the cache through the ASPDNSF admin page, but still no change.
Any idea what step I'm missing?
So this turned out to be me being an idiot. Many of the methods in XSLTExtensionBase have several overloads, I was just making the change in the wrong overload. Simply compiling the project is all you need to do to deploy, but you have to change the right code for it to render what you want!

Resources