Friday, November 16, 2012

Session Five - Threads @ IOM

SharePoint 2013 Chrome Control not applying style to SharePoint app

I have include a chrome control to my app using  reference specified in here. But in the first time it didn’t work properly. it just gave a page with out any styles.

image

But then inspecting errors I found jQuery library not loading correctly using the reference link  

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js

So I installed the jQuery to my project using nugget manager (you can do it manually as well)  and change the js reference to the project.


image


image


so it worked for me.


image

Thursday, November 1, 2012

An exception of type System.Management.Automation.CmdletInvocationException was thrown. Additional exception information: ErrorCode:SubStatus:Service running under Network Service account in workgroup environment is not supported.

This error occurred to me when I ran the product configuration wizard in the SharePoint 2013 Preview in the Standalone Mode. I found that is is because of the AppFabric running account.

Thus opening the SharePoint Management Shell and executing the following command resolved my issue.

psconfig.exe -cmd Configdb create SkipRegisterAsDistributedCacheHost

image

Wednesday, October 10, 2012

Object null reference Error when opening the Site / Document Library in the SharePoint

 

Server Error '/'  Application

Object reference not set to an instance of an object

Description: An unhandled exception was generated during the execution of the current web request. please review the stack trace for more information about the error and where it orginated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]

     Microsoft.office.server.Administration.UserProfileApplicationProxy.get_ApplicationProperties()  +134

Microsoft.office.server.Administration.UserProfileApplicationProxy.get_PartitionIDs() +44

Microsoft.office.server.Administration.UserProfileApplicationProxy.IsAvailable(SPServiceContext ServiceContext) +134

// -----------------------------------------------------------------------------------------------------------------------------

This error occurred in SharePoint installation on Windows Home Premium. But when I searched I found out this is happening because of the incorrect configuration of user profile service. Therefore I delete the user profile service application which help me to solve the issue.

Go to Manage Service Application in the Central Administration

image

Delete the User Profile Service Application

image

Friday, October 5, 2012

show headers when gridview is empty asp net

Here .NET 4.0 added a new property called ShowHeaderWhenEmpty in the grid view. So you can make it true in the gridview tag.

 <asp:GridView ID="gridAccounts" runat="server" ShowHeaderWhenEmpty="true" >

But in the other versions you need to add a blank row manually if no data found.

Tuesday, October 2, 2012

Create Client Context To Access SharePoint 2013 (Office 365 Preview) in AutoHosted SharePoint App Model using SharePoint client object model (CSOM)

If we are using SharePoint app model AutoHosted Environment we need to use Client Context model to access SharePoint.

Therefore First you need to get a Valid Access Token from SharePoint Server. For that you need to pass the SharePoint Site Url (This is available as SPHostUrl in the Query String) and Context Token that we can generate from passing the request Object.

TokenHelper Class provides methods that used can be used to access the SharePoint server and generate Access Tokens.

image

1. Get the Context Token by passing the HttpRequest

String context = TokenHelper.GetContextTokenFromRequest(Request);

2.Then get the Uri from the query string which provides the path to SharePoint server.

Uri SharePointUri = new Uri(Request.QueryString["SPHostUrl"]);

3. Then validate and generate access Token

SharePointContextToken contextToken = TokenHelper.ReadAndValidateContextToken(context, SharePointUri.Authority);
String AcessToken = TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;

4. Finally get a ClientContext By passing Url and AccessToken

ClientContext ClientC = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), AcessToken);

Monday, September 24, 2012

How to center a Div Horizontally and Vertically

 

.wrapper
{
width:100%;
height:100%;
background-color: aqua;
}

.body
{
width: 600px;
height: 300px;
background-color: #567;

position:absolute;
left: 50%;
top: 50%;
margin-left: -300px;
margin-top: -150px;

}
we set wrapper class to parent container. then set body css to child div which needs to center in the screen.

 


image

Saturday, September 15, 2012

Access to this web server is disabled by default because it is controlled by Basic Authentication and does not use Secure Socket Layer (SSL). Do you want to search the Microsoft Online Support Center to view possible solution?

I got this error when i tried to connect to  a SharePoint site using SharePoint designer. since I'm using Windows7 home premium as my development environment i configured the SharePoint to use basic  authentication which does not support SSL authentication.

But Microsoft provide hot fix to overcome this situation. You need to download and install the fix mentioned below.

[Microsoft Fix it 50711] http://go.microsoft.com/?linkid=9777384

Monday, September 10, 2012

The specified dsn contains architecture mismatch between the driver and application

image

This is a common error that is raising when 32bit applications and 64appications working together. therefore if you wan to create a 32bit DSN you should refer the 32bit DSN (ODBC) exe to create the DSN.

therefore you need to go to the folder called C:\Windows\SysWOW64. Therefore you need to run the ODBC exe in the location C:\Windows\SysWOW64\odbcad32.exe to over come the situation.

WOW is abbreviated as Windows on Windows

Tuesday, September 4, 2012

Do you want to show your Data mining Models in ASP.NET

Data mining models designed using Microsoft Analysis Services can be view in a web browser like your SSRS report.

You only need to do is to download the Web Control Library provided by the Microsoft and install the feature set.

Download:Microsoft SQL Server 2008 Service Pack 2 Feature Pack

Friday, August 24, 2012

Calculated Columns in .NET Data Tables (C#)

Recently I had a requirement to add Calculated Columns to Data Table. For an example I’m Only providing Amount and Quantity. Then discount will be calculated automatically.

String Discount = ".1";
DataTable workTable = new DataTable("Customers");

DataColumn workCol = workTable.Columns.Add("ID", typeof(Int32));
workTable.Columns.Add("UnitPrice", typeof(Double));
workTable.Columns.Add("Quantity", typeof(Int16));
workTable.Columns.Add("Total", typeof(Double));
workTable.Columns.Add("Discount", typeof(Double));

workTable.Columns["Total"].Expression = "UnitPrice*Quantity";
workTable.Columns["Discount"].Expression = String.Format("Total*{0}",Discount);
Later you can bind the Data Table to a Grid View if you need.
dataGridView1.DataSource = workTable;
dataGridView1.Update();

Special Note:


But my requirement was to update the Column Expression dynamically in the runtime. For an example Discount will be change according to the total amount. Therefore this method can not cater that requirement since  expression is fixed with the discount.


Thus I update the Column Expression in   dataGridView1_DataBindingComplete and invalidate the control for force data panting.

Double RunningSum = 0;
String ValDiscount = "50";
workTable.Columns["ValueDis"].Expression = String.Format("{0}/{1}*Total", ValDiscount, RunningSum.ToString());
dataGridView1.Invalidate();

Wednesday, August 22, 2012

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again

This error occurred to me when I introduce ElevatedPrivilages block to the project.

SPSecurity.RunWithElevatedPrivileges(delegate()
{…}
I refreshed the page and still I got the error. Then I found that I missed the
web.AllowUnsafeUpdates = true;
in the code.

Wednesday, August 15, 2012

What is the Different Between Eval() And Bind() in ASP.NET

Eval() is a one way binding mechanism therefore it can be used as a ReadOnly expression.

But Bind() works as a two way mechanism. therefore changes are getting reflect in the data source also.

Dynamically set Label BackColor (Control Back Color) in ASP.NET Grid

I engaged with fining a method of dynamically change control’s background color in a ASP.NET grid based on data in the data source.

I used the following code for get the task done.

<asp:TemplateField HeaderText="Color 01">
<
ItemTemplate>
<
asp:Label ID="lblColor1" runat="server"
BackColor='<%# System.Drawing.ColorTranslator.FromHtml((String)Eval("Color1")) %>' Text='<%# Bind("Color1") %>' >
       </asp:Label>
</
ItemTemplate>
</
asp:TemplateField>

Wednesday, July 25, 2012

ie window.open not working

When I tried to open a new window using JavaScript it worked for Google Chrome and IE. but didn’t work in IE.

window.open('url', 'B HELP', 'width=650');
I found that space character in title bar cause  the error. Therefore  I used the following code and it worked fine.
window.open('url', 'B-HELP', 'width=650');

Tuesday, June 26, 2012

@ NetAssist–24 June 2012 (9.00 am–1.00 pm)–Day 1

Questions Asked ?

  • About partial and full trust environments
  • Offline Database in MS that can use for small applications
  • SharePoint Web Services
  • SharePoint Flavors
  • What is the authentication mechanism use by SharePoint in Windows7 as a development environment

@ NetAssist–24 June 2012 (9.00 am–1.00 pm)

10175-June-2012

Day One – Intro (24 June 2012 )

Thursday, June 21, 2012

Role Based Security Using Form Authentication in ASP.NET , <Location path=’’ > not working and Login page does not have permission for anonymous users

I have created ASP.net web based application using Form Authentication. I need a section with role privileges and login page should be access by all users. when I specify the authorization in default section my login page loaded with out CSS since those files do not have permissions.

Thus I used following approach and it worked for me.

    <system.web>
<
authentication mode="Forms" >
<
forms name="SomeName" loginUrl="Login.aspx"
slidingExpiration="true" protection="None"
path="/" defaultUrl="Home.aspx" timeout="20" >
</
forms>
</
authentication>
</
system.web>
    <!--Permision for the site-->
<
location allowOverride="true">
<
system.web>
<
authorization>
<
deny users ="?" />
</
authorization>
</
system.web>
</
location>

<!--
Permision for the Login page-->
<
location path="Login.aspx">
<
system.web>
<
authorization>
<
allow users ="*" />
</
authorization>
</
system.web>
</
location>

<!--
permision setting section-->
<
location path="Settings">
<
system.web>
<
authorization>
<
deny users ="?" roles="User"/>
</
authorization>
</
system.web>
</
location>

Friday, June 15, 2012

Grid View Need Two clicks to change to Edit Mode in Visual Studio

This is a common mistake I'm forgetting every time. so I thought to publish a post.

We need to bind the grid again after selecting the EditRowIndex.

protected void gridSettings_RowEditing(object sender, GridViewEditEventArgs e)
{
gridSettings.EditIndex = e.NewEditIndex;
loadReportGrid();
}

Central Administration Page gives Blank Page

I have recently installed SharePoint 2010 in Windows 7 Home premium as described in http://msdn.microsoft.com/en-us/library/ee554869.aspx

but it gave an a blank page when I tried to start the central administration page. then after searching in the Net I found that windows 7 home edition , premium edition and some other editions need to enable basic from authentication in the IIS.

image

therefore  click the the relevant central administration web site and go to authentication option and change the basic authentication enabled.

Monday, June 11, 2012

The file is being used by another program Excel InteropServices

Recently my friend faced a problem when automating a program that written using excel InteropServices. This program work perfectly in debug mode  and Windows XP. but when it try to automate using task scheduler in Windows 7 , Vista and upper version it is giving following errors.

  • The file name or path does not exist
  • The file is being used by another program
  • The workbook you are trying to save has the same name as the currently opened book
  • The file name or path does not exist
  • The file is being used by another program
  • The workbook you are trying to save has the same name as the currently opened book

So creating a Desktop Folder in a following path resolved the issue.

C:\Windows\System32\config\systemprofile\Desktop

Refer:http://social.msdn.microsoft.com/Forums/en/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91

Friday, May 18, 2012

[IBM][isereis Access ODBC] .. SQL query exceeds specified time limit or storage limit ..

I got this exception when I tried to execute a query using DB2 ODBC script. There fore I found that ODBC property has a time out option which we can used to omit this problem.

image

go to configuration section and then Performance section and click  Advanced button.

image

and clear the option “Allow Query Time out

Monday, May 14, 2012

Slowly Changing Dimension (SCD) in SSIS is slow (Taking long time)

I encountered a problem when using the slowly changing dimension (SCD) in large databases. SCD is easy and fast when it comes to less number of records. therefore I used following mechanism to  speed up the process using available SSIS components.

image

First record set is send through Lookup command. in there we are checking that item is already available with the table.

If yes we are redirecting to UPDARE Command and If not we are redirecting to Insert Command.

But make sure following redirect option (Redirect rows to no match output) is set in the lookup component.

image

Wednesday, May 9, 2012

How to convert String to Enum Type in C#

This is a common question that we need in most of the time in developing. .NET provides powerful function in Enum Class to do that.

enum DBType
{
SQLSERVER,
ACCESS,
SQLCE
}
private static DBType getDBType()
{
String dbType = "SQLCE";
return (DBType)Enum.Parse(typeof(DBType),dbType);
}

Tuesday, May 8, 2012

Extensions Methods in C#

C# extensions can be used to extended the  functionality of already written class. (Yes it is true that we can use it for our classes as well. But then we can add the method directly rather than having it as extension method)

Following example shows a extension method which I used for extend the functionality of the windows.form class.

public static class Extensions
{
public enum SpliterModes
{
PanelOne,PanelTwo
}

public static void Show(this Form frm, String name)
{
frm.TopLevel = false;
frm.Visible = true;
frm.FormBorderStyle = FormBorderStyle.FixedSingle;
frm.MaximizeBox = false;
frm.Text = name;
}
}
image

Wednesday, May 2, 2012

Use Member Properties, Filter and With keyword in MDX

This is not a complete post. I came across a situation that I needed to show [Date] dimension values which is not empty as report parameter.

image

But I need yeas that only have values in measure. there for I used following MDX to get that.

with
member yKey as [Date].[Year].currentmember.uniquename
member yValue as [Date].[Year].currentmember.MEMBER_CAPTION
select{yKey,yValue}on 0,
{
filter([Date].[Year].[Year],[Measures].[Total Amount]<>null)
} on 1
from [RetailigenceBI]

this code result in getting


image

Tuesday, April 17, 2012

How to get Member Properties in MDX

Normally  MDX queries are returning caption for reports when we are using data in SSRS. But  we need other information such as UniqueNumber and other when passing as parameters to other reports and datasets.

Below shows example query used for get the member properties. (We can declare it using WITH MEMBER). DayKey is the custom column we are creating

with member DayKey as [Date].[Date].currentmember.uniquename
SELECT NON EMPTY
{
DayKey,[Measures].[Sample],
[Measures].[Sample2]

} ON COLUMNS,

NON EMPTY
{
[Date].[Year-Month-Date].[Date].ALLMEMBERS
} ON ROWS FROM [RetailigenceBI]

Tuesday, April 10, 2012

Month Sorting Issue in SQL Server Reporting Services (SSRS)

This error Occurred to me while I design the query in the Query Builder and generate the report in SSRS ( MDX). Months are showing alphabetical order (April , August,..) , but it should be January , February ..

I did some background works and even follows the the thread http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/27765eda-371d-4428-ab13-2e96b2fbb6ca.

But ultimately I  found there is a sorting adding by default to that column. I Deleted it ..

Bingo .. It worked .. 

image

Monday, April 2, 2012

Cross-thread operation not valid: Control xxx accessed from a thread other than the thread it was created on.

This error is occurring when  you are going to access the UI with another thread. There are method you can use to over come this situation.

The best approach is to use method Invoker to update the UI when it is required.

if (txtDataRx.InvokeRequired)
{
txtDataRx.Invoke(
new MethodInvoker(delegate { txtDataRx.Text = txtDataRx.Text + szData; }));
}
else
{
txtDataRx.Text = txtDataRx.Text + szData;
}

user profile synchronization service not starting in SharePoint 2010

I had a difficult time to get user profile service synchronization started. Following are the errors encountered to me when I tried to start the synchronization manually as well as through SharePoint.

Errors Encountered

  • Windows could not start the forefront identity manager synchronization services on local computer
  • The system cannot find the file specified. …
  • Windows could not start the forefront identity manager synchronization services on local computer
  • You account is not a member if a required security group (came from Forefront Identity Manager)
  • The Forefront Identity Manager Service cannot connect to the SQL Database Server.
  • Windows Could not start the Forefront Identity Manager Synchronization Service on local. for more info review the system event log. If this is a non Microsoft service contact the vendor and refer the specific error code 2145185792.

Workaround

These are things we need to consider to make it work.

  • First make sure you don’t give fully qualified name for the database in the SharePoint Product Configuration Wizard.

(giving the database name with domain postfix (fully qualified name) cause to connection issues in User profile synchronization service )

image

  • Add the User profile Synchronization user to Farm Administration Group.

image

  • Make sure the User profile Synchronization user in the Local Administrator Group.

image

 

  • Delegate the User profile Synchronization user to have Active directory access.

(How to add user profile service user to active directory delegation)

Go to the Active Directory User and Computer console.

image

Then Specify the user who want to access the Active Directory (this is use for synchronization).

image

Then Select Custom task to delegate.

image

Then delegate for folders and existing objects.

image

Then delegate active directory replication with general permissions.

 image

  • Then add the user for Active Directory Configuration.

For that go to run window and type adsiedit.msc

image

Then Go to properties and add the User profile Synchronization user to the configuration.

image

Then make sure that user is having Replicate Directory Changes permission.

image

  • And check whether you can start the two synchronization services manually by giving specified username and password. This will help you to identify any other errors related to the synchronization services (Forefront Identity Manager Service,Forefront Identity Manager Service Synchronization ).

image

First check whether you can start the services using specified username and password.

image

  • Check the User Profile Service User has relevant permission in the  user profile services. If not add it.

image

Then add the full control for the user.

image 

Other References

http://melick-rajee.blogspot.com/2011/07/user-profile-synchronization-service.html

Tuesday, March 27, 2012

How to add a Active Directory Domain Controller to Windows server 2008

This Active directory configuration I have did to configure VPC with SharePoint and  Active Directory services.

First you need to run the Active Directory service binary installation. therefore you need to run the “dcppromo”. Thus you can simply type it in the run window to execute it.

image

Then it checks the Domain services installations and prompt you for selection mode.

image

Select Use advanced mode installation and proceed to next.

image

This will prompt a compatibility note. So make it next to proceed. Then it will ask for forest configuration. since this is a new configuration we want to select create a new forest root domain.

image

after that it is asking domain name for the forest. therefore you can provide a fully qualified name for the domain.

image

the it will prompt for net bios name (you can leave the default)

image

After that it will ask the functionality level. I choose Windows Server R2. You can see the available functionalities in the description itself.

image

And Click the DNS.

image

Then it will warn for zone resolution. Make it yes to proceed.

image

Specify password for Admin Account to manage AD.

image

The proceed it to next.

image

after doing the configuration, wizard will take you to finish page.

image

Now you are done. Smile