Thursday, 30 April 2015

System.Net.WebException: The operation has timed out

I have modified below values in my Web.config, it has resolved my issue.

  <httpRuntime maxRequestLength="60000000" executionTimeout="60000000" />

 <requestFiltering>
       <requestLimits maxAllowedContentLength="60000000" />
     </requestFiltering>

Then you need to change applicationHost.config

open the %windir%\System32\inetsrv\config\applicationHost.config file

Change this:

From
<section name="requestFiltering" overrideModeDefault="Deny" />

To

<section name="requestFiltering" overrideModeDefault="Allow" />

If still you are facing error..try this..

HttpServerConnection objConn;
objConn.Timeout = 60000000;
ServicePointManager.MaxServicePointIdleTime = 60000000;

Ref:http://ajaxuploader.com/large-file-upload-iis-debug.htm

Tuesday, 28 April 2015

aras innovator System.Net.WebException: The operation has timed out

Case 1:
If you are using StreamReader or any request objects, you need to close it.

  HttpWebRequest r = WebRequest.Create("URL");
        HttpWebResponse w = r.GetResponse()

Close that objects..
 w.Close(); // Close connection  here.

Case 2: You are running your code from remote system, which is giving time out error..

Case 3: Your AML might be very big, split your AML in to 2 and try it..
Case 4: Your AML might be very big, split your AML in to 2 and try it and try to get only properties which are required in the select, if you don't specify the properties, aras will get all properties which will give time out error




Windows will report error #1053



Srvany is a utility developed by Microsoft that can start almost any regular, non-service application as a Windows Service.

Since a Windows Service must be specially constructed to interface with the operating system (to allow Windows to start, stop or pause it on demand), a regular application without this interface will not function properly as a Service. To solve the problem, Microsoft developed Srvany - an "adapter" (or "wrapper") that can accept the Windows Service commands and translate those into actions that a regular executable can understand.

Like any good adapter, Srvany is installed in between Windows and the application and handles all interaction between them. For example, when Windows says "Start the service", Srvany intercepts the request and starts the application as if you had double-clicked on it yourself.

Srvany was developed in the late 1990's for Windows NT and remains mostly unchanged to this day. It is available as part of the Windows Server 2003 Resource Kit Tools package.

Ref: http://www.coretechnologies.com/WindowsServices/FAQ.html#WhatIsSrvany

create service to run exe file

Open Command Prompt
Go to this path: C:\Windows\SysWOW64>
Type: sc.exe
 You will get all help commands..
To create a service you have to use..
sc.exe create  command

Ex: 
sc.exe create ServiceName binPath= "D:\myexeFile.exe" DisplayName= "MyService"

Make sure you give space after =

sc.exe start ServiceName
sc.exe stop ServiceName
sc.exe delete ServiceName

Good one: https://www.youtube.com/watch?v=X6o1AvZ06zc



Sunday, 26 April 2015

Aras innovator is current value is 1 for all rows

When i update an item in aras innovator, it was creating new row in the database and when i check the aras  is_current value, it was 1 for all rows.

Root Cause: you have not enabled Versionable
Solution: It should be 1 for latest row

Open Aras innovator
Go to Administration
Go to System Events--> Item Types
Search for your Item type.
Open it.
Unlock
Check "Versionable" check box
Save

Now you will see only one row  is_current =1


The type initializer for 'MyClass' threw an exception



Solution:

This problem can be caused if a class tries to get value of a key in web.config or app.config which is not present there.

Friday, 24 April 2015

An error occurred. Detailed message: 2 conflicts prevent checkout

Git error: An error occurred. Detailed message: 2 conflicts prevent checkout
Solution:

Close all your solutions
Open new visual studio
Connect to team foundation server
Connect to Git
Click on Home
Go to changes
If you see any Untracked files, those file are giving problem to you...
Take the back up of all your projects<Code>
Now delete Untracked files from Git.
Now Pull and sync

Thursday, 16 April 2015

You have insufficient permissions to perform 'add' operation." type="Aras.Server.Core.InsufficientPermissionsException”



Go to Aras Innovator UI
Click on Administrator -->Item Type
Search for “Manufacturer Part”
Select Manufacturer Part
Unlock

In the properties windows : “Can Add” you will find
Click on “Can Add”
Click on + icon
Search for Administrator
Add Administrator
Search for Component*
Add Component  Engineer
Save

Lock.

SQL Error String or binary data would be truncated. The statement has been terminated.

message =" String or binary data would be truncated. The statement has been terminated. " type =" System.Data.SqlClient.SqlException "

Root Cause:
Some if your input data is exceeding the length of the column.
In My came, i was having one column with name and length as 100, but i was sending 110 length name to database.

Solution: Increase the column size or trim input value..

Download SharePoint Server 2013

http://www.microsoft.com/en-us/evalcenter/evaluate-sharepoint-server-2013

Run Exe from bat file

Create a .bat file. ex: MyApp.bat
Call powershell script from batch file.


Now create a PS1 script ex" MyScript.PS1

Calling exe from Powershell

Powershell script to run exe


C# Deploy Class library with app config



While developing Class library, add app config and add all parameters.
Use all parameters in u r class library.
Now build, you will get dll (Run in release mode)

Now copy all dlls, exe and exe.config (Important), no need of app.config
Paste in to server.(All your config values will be available in exe.config)
Now run the exe from server.
Your code will execute...

Deployment using power-shell and batch file.
http://microsoft-techies.blogspot.com/2015/04/run-exe-from-bat-file.html

Open Event Viewer and Export logs to CSV file




Right-click the "Computer" icon on the desktop. If the "Computer" icon is not on the desktop, click the "Start" button to locate the "Computer" icon from within the Start Menu programs.

Click "Manage" from the options box to open the Computer Management Tools console

Click the right-facing arrow in front of the group "Event Viewer" to open the available Event Viewer logs

 Right-click the log to be exported, such as the "Security event log." From the available options, click "Save all Events as... ."

Click the down arrow in the "Save as type:" box and select "CSV (Comma Separated Value) (*CSV)."

 Click in the "File name:" box and type a file name and save location for the file. For example: "c:\SecurityEventLog" will save the file called SecurityEventLog and place it on the C: drive.

 Click "Save" to save the CSV file to the C: drive.
 Close the Computer Management Console by clicking the "X" in the upper right-hand corner of the console box.


Open CSV File in Excel and Sort by Event ID

1.Open CSV file. Select column data.
2.Click on Data in the top.
3.Click on Text to Columns

4. Select "Delimited" in the Wizard and click "Next."

5. Select "Comma" and deselect "Tab" under the Delimiters options and click "Next."

6. Select "General" under the Column data format box and click "Finish" to open the Event Viewer log in Excel.

7. Click on the "Event ID" column heading to highlight the entire column of Event IDs.

8. Click "Data" from the menu options at the top of the Excel application.

9. Click "Sort" from the Data menu tab, select "Expand the selection" when the Sort Warning box appears and click "Sort."

10. Click "Event ID" in the "Sort by" drop-down box, specify the sort order by selecting from the available options under the "Order" drop-down box and click "OK."

11. Review the list of Windows event IDs in Excel and save the file for future use.

Wednesday, 15 April 2015

Add custom revision ids in Aras Innovator

Open Aras
Go to Administration -->Revision
Right click "New Revision.."
Enter any name: CustomPartRevision
Under Revisions, Provide values: 1 2 3 4 5 6 7 8 9 10 11
your wish
A1 A2 A3 A4 A5
Save.

Now map above revision to Part.

Go to Administration -->ItemType
Run
Select Part
Unlock
Under revisions
Select ...
Run
Select new one
Save

You can do same way for Document and other Items...

c# xml to string

 string strIp = File.ReadAllText("c:\\a.xml");

Tuesday, 14 April 2015

Difference between Asp.Net and SharePoint execution

ASP.Net

SharePoint


c# xml to string XmlNodeType.EndElement is null


Visual Studio 2013 git, only Master branch listed

One of my team member has created new branch, now i want to use that branch.
When i open Visual Studio, i am able to see only master branch.
Solution:
Open Visual Studio
Connect to TFS
Click on Home.
Click on Branches
Click on Actions
Open command prompt
Type this command:
git checkout <Your Branch Name>
Or
Click on the the New Branch dropdown, and you will see all the remote branches.
Enter your Branch Name
Create Branch
Now you will see your branch.

There is an error in XML document (2,



I was trying to read XML file.
I have converted XML in to string, then i have Deserialize the string.
I was getting above error.

Solution:
While reading XML in to string, some of the XML values are decoding.
So those values are giving the error,i replaced actual values...

    XmlTextReader strreader = new XmlTextReader("c:\myxml.xml");
string temp = strreader.Value;

temp = temp.Replace("'", "&apos;").Replace("&", "&amp;").Replace("\"", "&quot;").Replace(">", "&gt;").Replace("<", "&lt;");

Ref more: http://microsoft-techies.blogspot.com/2015/04/read-special-characters-back-from.html


Read special characters back from XmlDocument in c#


Friday, 10 April 2015

Convert class library function into exe?

In the properties of the project -> application tag, change the Output type to console Application.
You need to create a static Main() method as a starting point.

static void Main(string[] args)
    {
    }

Wednesday, 8 April 2015

Monday, 6 April 2015

c# xml read There is an error in XML document (2, 2).

This is my xml
<?xml version='1.0' encoding='utf-16'?>
<Message>
<FirstName>Hunt</FirstName>
<LastName>DAvid</LastName>
</Message>
This is my code...
string xml = File.ReadAllText("c:\\Message.xml");
var result = DeserializeFromXml<Message>(xml);
I was getting error..
Solution:
Message class is missing XmlRoot

[Serializable, XmlRoot("Message")]
public class Message
{
public string FirstName { get; set; }
public string LastName { get; set; }
}

Delete a Git branch both locally and remotely

To delete any branch from VSO, you have to enable Alternate Authentication Credentials
Open VSO web browser.
Click on your name in the top right
Click on My Profile
Click on Credentials
Configure Alternate Authentication Credentials
Now open Visual Studio
Connect VSO.
Click on Team Explorer
Click on Home
Click on Branches
Click on Actions
Click on Open Command prompt
Now run below command to delete branch from GIT
git push origin --delete <Branch Name>

Friday, 3 April 2015

C# XML Deserialize in to Object - xmlns='' was not expected


<root element xmlns=''> was not expected.
{" was not expected.} XML Deserialize in C#

Change from standalone="yes"?> encoding="utf-8" ?>

Change from <?xml version="1.0" standalone="yes"?>  to <?xml version="1.0" encoding="utf-8" ?>

If you use Dataset.WriteXml("C:\\a.xml"); you will get  <?xml version="1.0" standalone="yes"?>

 objDataSet.WriteXml("C:\\a.xml");


If you use ..you will get <?xml version="1.0" encoding="utf-8" ?>

 XmlWriterSettings settings = new XmlWriterSettings();
                            settings.OmitXmlDeclaration = false;
                            XmlWriter objwriter = XmlWriter.Create("C:\\a.xml", settings);
                            objDataSet.WriteXml(objwriter);
                            objwriter.Close();

There are multiple root elements. Line 1, position 33

Solution:

Some where you are closing your element tag.
Ex:
Error: <Root/><Child>Hi</Child></Root>
Correct: <Root><Child>Hi</Child></Root>

C# XML read and remove namespace


DataSet WriteXML generates 'NewDataSet' root element



Solution:

 System.Data.DataSet myDs = new System.Data.DataSet("MyRoot");