Home » Microsoft Technologies

Extension for CSS Regions ?

Hi Guys,

Just wondering if anyone knows of an extension for CSS Regions ? I have some pretty big CSS files and I can't seem to locate how to create regions for these ? I have a Javascript region extension but not one for CSS ?



1 Answer Found


Answer 1

Hi SparkCode,

You can use a Macro to do it. For more information, please check following article:

Using #region Directive With javascript  Files in Visual Studio


Nancy Shao [MSFT]
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg @ microsoft.com



Using the VS2010 CC extension, in my VS 2010 Ultimate it displays wrongly when I collapse regions (#region).

The contract information then are somewhere randomly displayed, unfortunately I cannot paste a screenshot here.

Hi All,
I am very new to VB as my team manger ask me to code in VB instead of C# and I am not sure is this is a silly question. Anyway:

I like the use of #region in c# also in a method to make the code a little more readable. But it was not possible to use it in VB. I hoped this could change in the next version but I tried it in CTP and get the same message.

I would like to suggest this or an alternative to the new VB version. This should be implemented that other users on other systems using my codefile could also collaps the code part and see my comment to it.

If this is really a stupid question please let me know an alternative currently working.



Hi All,

I am using vsto 3 with VS2008 and developing the addin for office2007 outlook.

I am having a Replacement form region for my custom message class. Also having a seperate form region for the same message class. I am setting the replacement form regions manifest in factory initialize event as below

manifest.FormRegionType = FormRegionType.Replacement;
manifest.FormRegionName = "General";
manifest.Title = "";
manifest.ShowInspectorCompose = true;
manifest.ShowInspectorRead = true;
manifest.ShowReadingPane = false;

I am giving the Form region name as "General" so it will be available in ribbon under Show group with replacement form region name. I am not setting the title property as i dont want to add it in outlook Action menu but at run time it is showing in outlook under Action menu by the name of "New General".

It will not visible in Action menu if both FormRegionName and Title are blank but i have to set the form region name to show in ribbon.


Line 5282 of COREV4.css:

/* [ReplaceColor(V4_THEMING_COLOR_DAR2)] */ color:#3b4f65;


Other lines say: (eg. 5300)
/* [ReplaceColor(themeColor:"Dark1-Lighter")] */ color:#003759;


Here is the entire selector that probably won't work with themes:
/* [ReplaceColor(V4_THEMING_COLOR_DAR2)] */ color:#3b4f65;


I found this bug when parsing all themable CSS selectors in Corev4.css using excel. I noticed this was the only selector to contain a bracket, but not any of the following theme permutations: 

1.       "Light1"

2.       "Dark1"

3.       "Light2"

4.       "Dark2"

5.       "Accent1"

6.       "Accent2"

7.       "Accent3"

8.       "Accent4"

9.       "Accent5"

10.   "Accent6"

11.   "Light1-Lightest"

12.   "Dark1-Lightest"

13.   "Light2-Lightest"

14.   "Dark2-Lightest"

15.   "Accent1-Lightest"

16.   "Accent2-Lightest"

17.   "Accent3-Lightest"

18.   "Accent4-Lightest"

19.   "Accent5-Lightest"

20.   "Accent6-Lightest"

21.   "Light1-Lighter"

22.   "Dark1-Lighter"

23.   "Light2-Lighter"

24.   "Dark2-Lighter"

25.   "Accent1-Lighter"

26.   "Accent2-Lighter"

27.   "Accent3-Lighter"

28.   "Accent4-Lighter"

29.   "Accent5-Lighter"

30.   "Accent6-Lighter"

31.   "Light1-Medium"

32.   "Dark1-Medium"

33.   "Light2-Medium"

34.   "Dark2-Medium"

35.   "Accent1-Medium"

36.   "Accent2-Medium"

37.   "Accent3-Medium"

38.   "Accent4-Medium"

39.   "Accent5-Medium"

40.   "Accent6-Medium"

41.   "Light1-Darker"

42.   "Dark1-Darker"

43.   "Light2-Darker"

44.   "Dark2-Darker"

45.   "Accent1-Darker"

46.   "Accent2-Darker"

47.   "Accent3-Darker"

48.   "Accent4-Darker"

49.   "Accent5-Darker"

50.   "Accent6-Darker"

51.   "Light1-Darkest"

52.   "Dark1-Darkest"

53.   "Light2-Darkest"

54.   "Dark2-Darkest"

55.   "Accent1-Darkest"

56.   "Accent2-Darkest"

57.   "Accent3-Darkest"

58.   "Accent4-Darkest"

59.   "Accent5-Darkest"

60.   "Accent6-Darkest"

61.   "FollowedHyperlink"

62.   "Hyperlink"


V4_THEMING_COLOR_DAR2 is not listed as a permutation above, and not listed in the color picker Element: http://msdn.microsoft.com/en-us/library/ff458441.aspx so I figure it was a Microsoft bug. It also doesnt follow the syntax of the other themable selectors.

I have a pretty cool excel sheet that contains every themable selector in corev4.css, as well as the CSS attributes. Each column contains all 60 Themable selectors and marks which permutation is found in that particular selectors CSS attributes. This is nice, because I can find the Body selector, know what theme permutations are found in the attributes, and whether its the border, background, or color.

I will release this on my blog once its done. I'll post a link here too. :)




When I am building and running a webform, the link to a css file is two times in the head.
And the css is not working, can any one help me please.
The code is:

In the view source of the webpage:

   Home - MKB Databasebeheer
</titel><link href="App_Themes/MKB/MKB.css" rel="stylesheet" type=""text/css" /><link
hred="App_Themes/MKB/MKB.css" type="text/css" rel="stylesheet" /><style type="text">

The code in the master page is:

 <head runat="server">
  <title>Mkb Databasebeheer</title>
  <link href="App_Themes/MKB/Mkb.css" rel="stylesheet" type="text/css" />

The code in web.config is:

<page theme="MKB" masterPageFile="~/MKBDatabasebeheer.master: maintainScrollPositionOnPostBack="true" />

I hope that it is clear to you what I have done, and what I have done wrong?




I changed the CSS file (AppGrid.css.aspx) to format columns in view so that they are right-justified (CRM 4.0 )

is this supported by Microsoft or not ?


I have a css file in alternate url field, with !important styles.

the personalization site template includes the portal.css stylesheet twice (one before my file, another after) so styles in portal.css that use !important tag cannot be overriten.

anyone has had this issue?

I wonder if there is a simple workaround for this.



As we all now "Extension methods" are only methods, not getters/setters
I would love to have extension properties, I think you would all love...

Please mark post as helpful if you think it is...

I have been doing a little proof of concept and have run into a question.

1. The extension I have is one where I want to render a report and deliver it to a number of possible points, these being fax, print, file drop and email.  Thing is I want to sent to one single path or to any combination of the four.

To do this I pass the Notification object as is, the Subscription data in the form of string[,] and a debugging flag that determines how much data is written to the log files. Since my target dll does not have the IDeliver stuff and the IExtension implemented I have certain thing I have to do in the extension before I call the dll.

But since the dll has the Notification in it I can render the report in the dll. I did have to regiseter it with full trust in the security policies for both manager and server but it runs fine now. So I prototyped my emailing module and can email and log the image of the report and send off a copy to whoever. All working fine.

The question is when I fire up my dll I pass the Notification and I know that this is heavy lifting and it works, but is it okay?  I could render the report before  I call the delivery dll and pass in the byte[] and make it work, but is it okay to pass the Notification?  It lives in the same execution context and works so is it not recommended or does anyone know?



I have had a SharePoint 2010 server up and running for a few weeks now that pulls in accounts from our Active Directory system.  Today I noticed some accounts not being pulled over and when I checked the Forefront Synchronization Service Manager application to see what the problem was I found this error on several accounts that were being pulled over.

Here is the stack trace of the error:

Extension File Name: Microsoft.Office.Server.UserProfile.MetaversExtension.dll

Extension Type: provisioning


Call Stack Info:

System.ArgumentException: Item has already been added. Key in dictionary: 'DC=test,DC=testgroup,DC=org'  Key being added: 'DC=test,DC=testgroup,DC=org'

   at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)

   at Microsoft.Office.Server.UserProfiles.MetaverseExtension.MAMetaData.InitializeDomainInfoCache()

   at Microsoft.Office.Server.UserProfiles.MetaverseExtension.MAMetaData.GetDomainValue(ReferenceValue refVal)

   at Microsoft.Office.Server.UserProfiles.MetaverseExtension.MAMetaData.InitializeCSEntry(CSEntry csEntry, MVEntry mvEntry)

   at Microsoft.Office.Server.UserProfiles.MetaverseExtension.MVExtensionObject.Microsoft.MetadirectoryServices.IMVSynchronization.Provision(MVEntry mventry)


Any thoughts on what could be causing this?


Im trying to create an extension (menu item) that generates a class based on what a stored procedure returns. The menu item only shows up in the stored procedure right click menu. I have the menu item, it works great, but cannot get the selected stored procedure name. It returns "System.__ComObject". As you will see in the code, I have been trying to determine the type using VisualBasic.Information.TypeName().

Reason I need this: I have a data access layer that targets only stored procedures on a SQL database (due to company policy). It takes a type, creates a new instance of it, then populates it with the data returned from the SP using reflection on the column name. Which, leads me to this extension I am creating. I would rather generate the class than have to spend the time coding it.

Here is the code for the extension (Yes, I used the wizard):

///<summary>/// Initialization of the package; this method is called right after the package is sited, so this is the place/// where you can put all the initilaization code that rely on services provided by VisualStudio.///</summary>protectedoverridevoid Initialize()
      Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));

      // Add our command handlers for menu (commands must exist in the .vsct file)
      OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

      if (null != mcs)
        // Create the command for the menu item.
        CommandID menuCommandID = new CommandID(GuidList.guidEntityGeneratorCmdSet, (int)PkgCmdIDList.cmdIdGenerateEntity);
        MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
    #endregion///<summary>/// This function is the callback used to execute a command when the a menu item is clicked./// See the Initialize method to see how the menu item is associated to this function using/// the OleMenuCommandService service and the MenuCommand class.///</summary>privatevoid MenuItemCallback(object sender, EventArgs e)
      // Show a Message Box to prove we were here
      IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
      Guid clsid = Guid.Empty;
      int result;

      string selected = GetSprocSignature(sender, e);

            ref clsid,
            string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback(): {1}", this.ToString(), selected),
            0,    // falseout result));

    privatestring GetSprocSignature(object sender, EventArgs e)
      MenuCommand menuCommand = sender as MenuCommand;

      string selected = "nothing";
      if (menuCommand != null)
        IntPtr hierarchyPtr, selectionContainerPtr;
        uint projectItemId;
        IVsMultiItemSelect mis;
        IVsMonitorSelection monitorSelection = (IVsMonitorSelection)Package.GetGlobalService(typeof(SVsShellMonitorSelection));

        selected = Microsoft.VisualBasic.Information.TypeName(monitorSelection).ToString();
        //monitorSelection.GetCurrentSelection(out hierarchyPtr, out projectItemId, out mis, out selectionContainerPtr);//IVsHierarchy hierarchy = Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)) as IVsHierarchy;//if (hierarchy != null)//{//  object value;//  hierarchy.GetProperty(projectItemId, (int)__VSHPROPID.VSHPROPID_Name, out value);//}

      return selected;


Is there any way to uninstall VS2010 extension correctly without the Extension Manager? I couldn't find any special command line arguments for .vsix file and think that just deleting all the files from Visual Studio's special place is not a right solution.




This thread can be consider as a continuation of my previous thread . I hope you could better look into that for get the clear idea . Though now I'm investigating how could i start with Test Agent i need to know why i'm getting this error when i tried to execute test scripts with MSTest.exe . I think Test Agent will be a good solution for these kind of issues .

In further observations i noticed that there is a registry for valid test types in  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\EnterpriseTools\QualityTools\TestTypes and for this instance it is set correctly .

Why i'm getting this error ?? If someone can explain the reason and how could i fix it that will be great .

Thanks in advance



I use Visual Studio 2010 Professional, and I am looking to become experienced as an add-in author so I can create things like the VS10x Code Map and the Productivity power tools that are very useful to me.  I want to be able to get an idea along the same lines as and have the power to do it myself.  Recently I've been refactoring alot and wishing I could have the namespace change as a result of drag and drop operation, and I am asking this yes/no question just as an acid test to see if my thinking is in line with the domain of the possible/reasonable.

Note: this is my first post, so I apologize in advance if I'm missing any kind of boat which in turn makes my question silly/stupid/otherwise.  I promise it's not my intention to waste anyone's time.






I'm creating an processing data extension for SQL 2008 R2 by following instructions http://msdn.microsoft.com/en-us/library/ms154655.aspx. When I try to check the deployment on the server side I'm getting the error in the log file:

e ERROR: Exception caught instantiating MSCRMONLINE report server extension: System.BadImageFormatException: Could not load file or assembly 'Microsoft.BPCRM.DataProcessingExtension' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'Microsoft.BPCRM.DataProcessingExtension'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at Microsoft.ReportingServices.Diagnostics.ExtensionClassFactory.LoadAssembly(String name)
   at Microsoft.ReportingServices.Diagnostics.ExtensionClassFactory.<>c__DisplayClass2.<CreateExtensionObject>b__0()
   at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.<>c__DisplayClass1.<Run>b__0(Object state)
   at System.Security.SecurityContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
   at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.Run(ContextBody callback)
   at Microsoft.ReportingServices.Diagnostics.ExtensionClassFactory.CreateExtensionObject(Extension extConfig, Boolean typeOnly)

For development I'm using VS 2010 and .NET Framework 4. Is there any way to use extensions compiled for .NET 4?




I have an VS2010 Extension that uses USB communication.  The USB class that I'm using requires that the WM_DEVICECHANGE message be handled to detect USB attach/detach events.  I have implemented this by using HwndSource.AddHook() in the past, but never in a VS Extension.

What is the reccomended implementation for hooking into the Windows message pump in a VS 2010 Extension?


Is there setting or something that will show the extension of office files (.doc, .docx, .xlsx etc...) when i search? 

The strange thing is that i have used the exact same XSL code in test as I am using in Live.

so my Search results on test will look like this:

<PDFIcon> Regular Expression.pdf

<DocIcon> Regular Expression.doc

so my Search results on LIVE will look like this:

<PDFIcon> Regular Expression.pdf

<DocIcon> Regular Expression

Here is some trimmed out XSL code that is IDENTICAL on both test and Live:

<xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:paramname="ResultsBy"/><xsl:paramname="ViewByUrl"/><xsl:paramname="ViewByValue"/><xsl:paramname="IsNoKeyword"/><xsl:paramname="IsFixedQuery"/><xsl:paramname="ShowActionLinks"/><xsl:paramname="MoreResultsText"/><xsl:paramname="MoreResultsLink"/><xsl:paramname="CollapsingStatusLink"/><xsl:paramname="CollapseDuplicatesText"/><xsl:paramname="AlertMeLink"/><xsl:paramname="AlertMeText"/><xsl:paramname="SrchRSSText"/><xsl:paramname="SrchRSSLink"/><xsl:paramname="ShowMessage"/><xsl:paramname="IsThisListScope"/><xsl:paramname="DisplayDiscoveredDefinition"select="True"/><xsl:paramname="NoFixedQuery"/><xsl:paramname="NoKeyword"/><xsl:paramname="NoResults"/><xsl:paramname="NoResults1"/><xsl:paramname="NoResults2"/><xsl:paramname="NoResults3"/><xsl:paramname="NoResults4"/><xsl:paramname="DefinitionIntro"/><!-- When there is keywory to issue the search --><xsl:templatename="dvt_1.noKeyword"><spanclass="srch-description"><xsl:choose><xsl:whentest="$IsFixedQuery"><xsl:value-ofselect="$NoFixedQuery"/></xsl:when><xsl:otherwise><xsl:value-ofselect="$NoKeyword"/></xsl:otherwise></xsl:choose></span></xsl:template><!-- When empty result set is returned from search --><xsl:templatename="dvt_1.empty"><divclass="srch-sort"><xsl:iftest="$AlertMeLink and $ShowActionLinks"><spanclass="srch-alertme"><ahref="{$AlertMeLink}"id="CSR_AM1"title="{$AlertMeText}"><imgstyle="vertical-align: middle;"src="/_layouts/images/bell.gif"alt="" border="0"/><xsl:textdisable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:value-ofselect="$AlertMeText"/></a></span></xsl:if><xsl:iftest="string-length($SrchRSSLink) &gt; 0 and $ShowActionLinks"><xsl:iftest="$AlertMeLink">
    </xsl:if><atype="application/rss+xml"href="{$SrchRSSLink}"title="{$SrchRSSText}"id="SRCHRSSL"><imgstyle="vertical-align: middle;"border="0"src="/_layouts/images/rss.gif" alt=""/><xsl:textdisable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:value-ofselect="$SrchRSSText"/></a></xsl:if></div><br/><br/><spanclass="srch-description"id="CSR_NO_RESULTS"><xsl:value-ofselect="$NoResults"/><ol><li><xsl:value-ofselect="$NoResults1"/></li><li><xsl:value-ofselect="$NoResults2"/></li><li><xsl:value-ofselect="$NoResults3"/></li><li><xsl:value-ofselect="$NoResults4"/></li></ol></span></xsl:template><!-- Main body template. Sets the Results view (Relevance or date) options --><xsl:templatename="dvt_1.body"><!-- LAF: Custom Script Section Begin --><scriptlanguage="javascript"type="text/javascript"implements-prefix="my"><xsl:text>
function SendEmailWithLink(link) 
 var link = "mailto:?body=" + escapeProperly(link);
 return false;
</xsl:text></script><!-- LAF: Custom Script Section End --><divclass="srch-results"><xsl:iftest="$ShowActionLinks"><divclass="srch-sort"><xsl:value-ofselect="$ResultsBy"/><xsl:iftest="$ViewByUrl">
      <spanclass="srch-alertme"><ahref="{$AlertMeLink}"id="CSR_AM2"title="{$AlertMeText}"><imgstyle="vertical-align: middle;"src="/_layouts/images/bell.gif"alt="" border="0"/><xsl:textdisable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:value-ofselect="$AlertMeText"/></a></span></xsl:if><xsl:iftest="string-length($SrchRSSLink) &gt; 0">
      <atype="application/rss+xml"href="{$SrchRSSLink}"title="{$SrchRSSText}"id="SRCHRSSL"><imgstyle="vertical-align: middle;"border="0"src="/_layouts/images/rss.gif" alt=""/><xsl:textdisable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:value-ofselect="$SrchRSSText"/></a></xsl:if></div><br/><br/></xsl:if><xsl:apply-templates/></div><xsl:call-templatename="DisplayMoreResultsAnchor"/></xsl:template><!-- This template is called for each result --><xsl:templatematch="Result"><xsl:variablename="id"select="id"/><xsl:variablename="url"select="url"/><xsl:variablename="title"select="title"/><spanclass="srch-Icon"><ahref="{$url}"id="{concat('CSR_IMG_',$id)}"title="{$url}"><imgalign="absmiddle"src="{imageurl}"border="0"alt="{imageurl/@imageurldescription}"/></a></span><spanclass="srch-Title"><ahref="{$url}"id="{concat('CSR_',$id)}"title="{$title}"><xsl:choose><xsl:whentest="hithighlightedproperties/HHTitle[. != '']"><xsl:call-templatename="HitHighlighting"><xsl:with-paramname="hh"select="hithighlightedproperties/HHTitle"/></xsl:call-template></xsl:when><xsl:otherwise><xsl:value-ofselect="title"/></xsl:otherwise></xsl:choose></a><br/></span>
 <!-- End of Stylesheet --></xsl:stylesheet>


WCF Custom BeaviorExtension Error: An extension already appears in extension collection. Extension names must be unique.

I have a custom behaviorExtension for a silverlight project which helps in communicating faultcontract messages to client. This error occurs when the service is called. Works good in Dev and QA boxes but not in PROD test server. Any ideas of where to start and how to debug ?

Platform: .NET 3.5, Silverlight, WCF

Any help is appreciated.

web.config section:

        <add name="silverlightFaults"
            type="Mrr.Srsa.Services.SilverlightFaultBehavior, Mrr.Srsa.Services, Version=, Culture=neutral, PublicKeyToken=9e9f5a95ab06f177"/>
        <behavior name="SilverlightFaultBehavior">
            <silverlightFaults />

Hi All,
Again stuck with an issue. I have created a replacement form region which is very similar to preview form region of outlook with few more fields. The problem i am facing is that outlook is showing the attachment list in mutliline if there are more than one attachment and it take more space then its width. While in my case the customized form region is showing only one line with up/down button. I had seen all the property of DocSiteControl but dont find any property which enable this option. But if i am selecting any attachment in both the form regions then it comes same, and when click on message, again the same problem with customized form region only.
I am using VS2008 with VSTO office 2007.

In vs 2008 (vb.net) I had an option to highlight some code, right click, and select (Surround With...) and choose "Region".

That option is not there in 2010, so maybe it was part of the free Refactor! tool which is no longer available with VS2010.

So... I'm off to find how I can get this functionality back.  I know all C# users have had this forever as a snippet but because VB users are the bastards sons of Microsoft programming we don't get that.  So I created my own Region snippet much like the one provided for C#, however it seems like if you are using VB.net you can't use "SurroundWith" snippets.

Is this correct?  I can't find any documentation on this at all.




<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure