Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Friday, September 28, 2012

Wikipedida Wikimedia query returns 403 forbidden

I had the following webclient request 
 WebClient serviceRequest = new WebClient();
var JsonResponse = serviceRequest.DownloadString(new Uri(urselected));

Where urselected was the REST query string. The query worked fine in my browser but returned 403 forbidden error. I found the following post which addresses the problem:

Wikipedia query returns error 403

Modified my code as follows and it worked find:

WebClient serviceRequest = new WebClient();
           serviceRequest.Headers.Add("user-agent", "Silver Azure");

           var JsonResponse = serviceRequest.DownloadString(new Uri(urselected));

Tuesday, August 28, 2012

visual studio express 2012 for web installation experience or frustration !

I thought I would share my experience in installing visual studio express for web installation. The indication regarding installation was not very good in the beginning of the installation. So I thought I will outline my experience which might be useful for some one!

  1. Downloaded the ISO file from Visual Studio 2012 downloads
  2. Double clicked on the file in Explorer. It prompted me to  burn   a disk which I did.
  3. 9:40 Am: Started installation from disk.
  4. Progress bar was stuck-up in installing .net 4.5
  5. Thought of canceling, but went and had a coffee
  6. 10:17 Am: Progress bar was still stuck, no indication and suddenly finished and prompted for  restart
  7. After restart, seemed to be showing progress bar with meaningful indication
  8. 10:35 Am Microsoft Visual Studio Express 2012 for web-ENU takes a long time: progress bar struck about 1/3rd
  9. 10:40 AM: progress bar moved to 1/2!
    the bottom assembly installation names started changing faster!
  10. 10:45AM: Setup Successful !
  11. When you open the Visual Studio Express it prompts you to get a key which I did.

My system
gateway NE56R13u
Celeron 1.7 GHz, 64 bit, 4 GB RAM,
Windows 7 ultimate service pack 1

Tuesday, August 21, 2012

HTML Javascript IDE for development and Tips for Developing with Visual Studio Express

When I have a web page development project or issue, I try to divide the project into smaller tasks and do experimental web pages to try out new ideas or resolve bugs.

So I needed a development IDE for HTML, Javascript and CSS. Tried Aptana Studio, Microsoft Expression Web 4 and Visual Studio Express, netbeans.

Found Visual Studio 2010 Express Products to be  the best. I have to warn you that I am little bit prejudiced because I am very familiar with Visual Studio because of my C#, .net, Silverlight development experience.

What I like about the IDE is it has some Intellisense, you can collapse divs in HTML . For example if you want to add a reference like the following

<script src="js/triangle_1.js" type="text/javascript"></script>

you can just drag the file from the folder view and drop it in your html file.

I did not want to create a web site for the small files I work with. I already had a few HTML files and associated folders with Javascript and CSS files in a folder with name JQM1. I asked the Visual Studio Express to start a new empty C# web solution and pointed to the JQM1 folder. It said you already have a project, I said yes and the folders showed up.

You can also look at the html pages using the File Web browser option. Since I work a lot with CSS3, I have designated Safari as my default browser and it works fine!

Try it , you may like it. One warning though the installation process took more than an hour and there is a registration process for Visual Studio Express using windows live id, but it is free!

Excellent reference Visual Studio shortcut keys

Friday, January 28, 2011

Windows Phone 7 Silverlight, Adcontrol step by step, tricks and issues

Went through interesting experience in implementing the adcontrol in Windows Phone 7 and I thought I will share it here.

First go and register your application in

Microsoft Pubcenter

This site gives you the following steps

  1. Register mobile application
  2. Create application ad unit
  3. Download the Microsoft Advertising SDK for Windows Phone 7
  4. Integrate the Microsoft Advertising SDK for Windows Phone 7 into your application.
  5. Manage your existing applications and ad units

In the XAML insert the ad control

<StackPanel Grid.Row="5"   x:Name="SP_ADControl" Visibility="Visible"   >

<ad:AdControl RotationEnabled="True" AdModel="Contextual" Width="450" Height="80"
AdUnitId="your adunit id" ApplicationId="your application id" />

<!--<ad:AdControl Width="450" Height="80"
AdUnitId="TextAd" ApplicationId="test_client" />-->

</StackPanel>



In my application Grid.Row=”5” is the bottom portion of the screen. Do not forget to pu your own ApplicationID and AdUnitId. The commented out portion is what you can use to test the app without getting an app id from the pub center.



In the Xaml.cs file put the following in the code right after InitializeComponent();



  if (!CheckIsTrial())
{
SP_ADControl.Visibility = Visibility.Collapsed;
}
else
{
// Show_Buy_Now_Page();
SP_ADControl.Visibility = Visibility.Visible;
AdControl.TestMode = false;
}



Add this method to the code



private bool CheckIsTrial()
{
#if DEBUG
MessageBoxResult result = MessageBox.Show
("CLICK OK TO SIMULATE FULL LICENSE", "BUY NOW!", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
return false;
}
else
{
return true;
}
#else
return licenseInfo.IsTrial();
#endif
}



This would help to test the app in the debug mode by showing you a dialog to test the ap. Check reference 5 given below.



The most interesting line of code is  AdControl.TestMode = false;  This is required because the Adcontrol.TestMode default value is True! Check reference 1 and 2 on this.



Do not forget to submit the release version to the marketplace.



References




  1. Making the MS Adcontrol REALLY work on phone 7


  2. WP7 – Using the Microsoft AdControl


  3. Integrating the AdControl into an Application Programmatically (C#)


  4. Microsoft Advertising SDK for Windows Phone 7


  5. How to: Test and Debug your Trial Application


  6. Tips on Using the AdControl in Windows Phone 7

Friday, December 31, 2010

Windows Phone Connect Tool without Zune from Visual Studio

You need Zune to connect from Visual Studio 2010 to Windows Phone 7 Device to deploy applications from Visual Studio. This connection mode does not let you allow to debug with Media Library.

You can connect to Windows Phone 7 from Visual Studio 2010 using the Windows Phone 7 Connect Tool.

The following link from  Sebastian Schütze’s blog is   helpful:

Debug with Windows Phone without using Zune

Get the following tool

Windows Phone Developer Tools October 2010 Update.

Use the following link to use the Connect Tool

How to: Use the Windows Phone Connect Tool

I have given  below excerpts from this web site

To use the Windows Phone Connect Tool
  1. Open a command prompt and navigate to the directory containing the Windows Phone Connect Tool (WPConnect.exe). The location of this file will be %ProgramFiles%\Microsoft SDKs\Windows Phone\v7.0\Tools\WPConnect for 32-bit installations. For 64-bit installations it will be located at %ProgramFiles (x86)%\Microsoft SDKs\Windows Phone\v7.0\Tools\WPConnect.

  2. Connect your Windows Phone to your computer and ensure that it is detected by the Zune software.

  3. Close the Zune software after your Windows Phone is connected.

  4. At the command prompt, enter the command WPConnect.exe.

    NoteNote:

    You will receive confirmation that your device is now connected. Also, you do not need to disconnect from this tool. At any time, you can re-establish connectivity with the Zune software by launching the Zune software. However, after reestablishing connectivity with the Zune software, you must repeat the preceding steps if you want to debug an application with media APIs.

You should now be able to debug your application without the Zune software running.

Wednesday, December 15, 2010

Windows Phone 7 XImporters, TextureImporters error

I wanted to run some of my old XNA projects which gave me a cryptic error message XImporters or TextureImporters missing. When I looked in my references these assemblies where there and properly referenced.

Then I came across this blog Assembly references in XNA Game Studio 4.0 beta projects need to be updated after installing the final release by Aaron Stebner.

As per Aaron’s recommendation I removed all references to the Microsoft.Xna.Framework.Content.Pipeline assemblies and added them again. It worked.

The assemblies are in the following folder: C:\Program Files\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\

The offending assemblies in my project were:

Microsoft.Xna.Framework.Content.Pipeline.AudioImporters
Microsoft.Xna.Framework.Content.Pipeline.EffectImporters
Microsoft.Xna.Framework.Content.Pipeline.FBXImporters
Microsoft.Xna.Framework.Content.Pipeline.TextureImporters
Microsoft.Xna.Framework.Content.Pipeline.VideoImporters
Microsoft.Xna.Framework.Content.Pipeline.XImporters

a

Monday, October 4, 2010

Azure error SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used

When you start Visual studio azure project using development storage if you get the following error

SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used

go to webrole.cs and modify OnStart code to

public override bool OnStart()
{
DiagnosticMonitor.Start("DiagnosticsConnectionString");

// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
// RoleEnvironment.Changing += RoleEnvironmentChanging;
#region Setup CloudStorageAccount Configuration Setting Publisher

// This code sets up a handler to update CloudStorageAccount instances when their corresponding
// configuration settings change in the service configuration file.
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
{
// Provide the configSetter with the initial value
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));

RoleEnvironment.Changed += (sender, arg) =>
{
if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
.Any((change) => (change.ConfigurationSettingName == configName)))
{
// The corresponding configuration setting has changed, propagate the value
if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
{
// In this case, the change to the storage account credentials in the
// service configuration is significant enough that the role needs to be
// recycled in order to use the latest settings. (for example, the
// endpoint has changed)
RoleEnvironment.RequestRecycle();
}
}
};
});
#endregion

return base.OnStart();
}

This should work!

Saturday, October 2, 2010

Convert XML files to class files in Visual studio

xsd.exe gtest1.xsd  /cThese are the steps to convert xml files to class files in Visual Studio.

  1. Open the XML file in Visual Studio.
  2. Create Schema in the XML option.
  3. Run the Visual Studio command prompt from programs.
  4. Cd to the relevant file:
    1. cd C:\test1\test2\\xml_files
  5. To convert file
    1. xsd.exe test1.xsd  /c
  6. to convert multiple files
    1. xsd.exe test1.xsd test2.xsd  /c
  7. when converted individually lot of duplicate names had to be commented out.
  8. Easier approach use the XSD files create constructor for each item.

Friday, July 23, 2010

Winphone XNA deployment in Toshiba Satellite L305-S5944

Finally I think that I have the XNA game studio working in my Toshiba laptop. It did not have the 10.1 directx capability. Hence I did the following:

  1. Downloaded Intel® Graphics Driver for Windows 7* and Windows Vista* (exe) from Intel site. Ran it with lot of trepidation because I was worried the screen is going to become blank! It failed. Ran it again! It updated the driver.
  2. Compiled a Windows Phone application and it failed.
  3. Ran dxdiag which showed that I had 10.1 installed.
  4. Downloaded and installed DXSDK_June10.exe. This is not required, but I did it to get the DirectX Caps Viewer Tool mentioned in the Release notes.
  5. Ran the C:\Program Files\Microsoft DirectX SDK (June 2010)\Utilities\bin\x86\DXCapsViewer.exe and checked the results. It looked OK. I expanded the Direct3D 10.1 folder and saw entries for  D3D10_FEATURE_LEVEL_10_0 or D3D10_FEATURE_LEVEL_10_1. Direct3D_11 folder also had similar entries for D3D_FEATURE_LEVEL_10_0.
  6. Tried to install the following and it said not applicable to my system!
    1. Update for Windows Vista (KB971512)
    2. Update for Windows Vista (KB971513)
    3. Update for Windows Vista (KB971514)
    4. Update for Windows Vista (KB960362)
  7. Tried to deploy the Winphone application. Same error.
  8. Became bold and adventurous!  followed this instruction:
    1. It is possible to bypass this capabilities check in XNA Game Studio by setting the following registry setting: HKEY_LOCAL_MACHINE\Software\Microsoft\XDE XNAEnableGPU = 1 (REG_DWORD)Caution: If you override this registry key, the project will attempt to deploy but only a black screen will be displayed in the emulator if the required graphics card capabilities are not available.
  9. Voila! I was able to deploy. This is an empty application. Will check with the Hello world and update this post again!
  10. Update: Unfortunately this does not work. Posted in the Windows Phone forum.WDDM 1.1 driver, The current display adapter does not meet the emulator requirements to run XNA
  11. Will be updating laptop to windows 7. Let us see whether this solves the problem!
  12. Windows 7 resolved it!

Wednesday, May 19, 2010

Silverlight InitializeError- Invalid or malformed application: Check manifest Changing Namespace

I recently changed the namespace in a Silverlight project and ran into lot of problems! Visual Studio was smart to change the namespace in many files, but I ran into this bug and the page will not render

InitializeError- Invalid or malformed application: Check manifest.

I researched this and came across this forum posting:

InitializeError- Invalid or malformed application: Check manifest

First I learnt an easy way to  look at the XAP file. Just change the extension to .zip and you can unzip it and look in the App.Manifest file. No problem there. Then going through the thread I found the solution as recommended by R. Wiltschek. Quoting him

“In human-readable words, this is what fixed it for me: 1. Open the properties of your project. 2. On the first page, open the drop down list of "Startup object". 3. Select the page your project starts with. In my case, changing the name of the namespace broke the startup object.”

It worked for me!

Dynamic C#, Visual Studio 2010, OData

Attended a talk by Kevin Pilch-Bisson and Ryan Dawson on

Sneak peak at the new language features of .Net 4.0 and VS2010.

Very good demo by Kevin on using the dynamic C# features to interface to Office Word and Excel without going through lot of COM idiosyncrasies, and Javascript interface which enables you to use C# classes.

Ryan talked about IronPython and IronRuby which looks interesting.

Attended an all day OData event by Douglas Purdy and Jonathan Carter. The presentation was similar to the one in MIX10. Exciting technology, might be useful for XBRL data presentation.

Thursday, May 6, 2010

Silverlight Visual Studio how to add existing Silverlight projects

When you want to use existing Silverlight projects (like demos from Devexpress Silverlight AgGrid) in Visual Studio do the following:

  1. Start a Silverlight Application
  2. Host it in a new web site.
  3. Add the Silverlight Project.
  4. Right click on Web application
  5. Select Properties.
  6. Select Silverlight Applications tab
  7. Press the Add button
  8. Use existing project radio button will be normally selected.
  9. The drop down menu will show you the Silverlight projects available in the solution.
  10. Select add a test page.
  11. Leave the destination folder as ClientBin
  12. Press the Add button.
  13. A test page is added
  14. The XAP file from the silver light project is added to the ClientBin.
  15. Every time you make changes in the silver light project and compile the solution is updated.
  16. Sometime the F5 (Compile and Run) button in Visual Studio does not use the updated file.
  17. You may have to do a compile first and then run it.

Wednesday, May 5, 2010

WCF, Silverlight , Ajax development with Visual Studio

Visual studio offers 2 templates for adding WCF.
The following quote from WCF Visual Studio Templates explains the 2 types:

“AJAX enabled WCF Service Item Template
This template exposes an AJAX control as a WCF service. For more information on AJAX controls, see the AJAX control documentation.

Silverlight-enabled WCF Service Item Template
This template creates a Web service that provides data to a Silverlight client or front-end. The template can be added to a Web site or Web application project to create a WCF service, which includes service code and configuration that support communicating with a Silverlight client. You can then use Add Service Reference to add a client proxy of the service to the client, and exchange data between the Silverlight client and the Silverlight-enabled WCF service.

To access this template, right-click a Web site or Web application project in Solution Explorer, click Add a new item, and click Silverlight-enabled WCF Service.

Visual Basic Note: 
The Silverlight-enabled WCF Service exposes a basicHttpBinding endpoint without enabling any security settings. Therefore, information about the service can be obtained by all clients that connect to this service. Messages exchanged between the service and the client are also not signed or encrypted. To secure the endpoint properly, you should use ASP.NET authentication, HTTPS or other mechanisms. “

Schleichermann has an excellent blog on this topic:  .Net: Difference Between WCF Service and Silverlight-Enabled WCF Service

Muhammad Adnan Amanullah also has an interesting article on this topic:  Ajax enabled web service where he describes how to Make Script based web service which could be called by JavaScript.

Monday, May 3, 2010

SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used error in Azure, Visual Studio

I copied one of the Azure solutions Thumbs_E1(which was working)  to Thumbs_E1_SL1 folder  along with the project folders to a new folder. Changed all folder names to correspond with the new extension I had.

Thumbnails_E1_WorkerRole to Thumbnails_E1__SL1_WorkerRole
Thumbnails_E1_WebRole to Thumbnails_E1__SL1_WebRole
Thumbnails_E1 to Thumbnails_E1_SL1

When I opened the solution it complained about the projects not being there. I removed the projects folder icons and added the projects again from the renamed folders.

It compiled fine, but would not run and gave me an error

System.InvalidOperationException: SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used.

I found a solution in the following link

Using the CloudStorageAccount.FromConfigurationSetting

Set the Thumbnails_E1 as the start up project and it worked!