C#,vb.net,MVC,Jquery,javascript,jscript,vbscript,html,vb,sharepoint,COM,WPF,WCF,Wwf,Asp,Asp.net,questions & answers,

Latest in Sports

Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Monday, September 9, 2019

Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll' or one of its dependencies. The system cannot find the file specified.?



Solutions:

1. Edit the unit test .csproj and change the item references from <Shadow Include="Test References\namespace.accessor" /> to <None Include="Test References\namespace.accessor" /> (Shadow => None).

2 Better yet, simply delete all the .accessor files from the unit test project's Test References folder.

This really works for me.

Tuesday, October 14, 2014

I have a requirement of building my project setup file using Command Line or C# code.
I tried using "devenv", but it didn't work.

Can any one please provide any suggestions?

ANSWER:

To build single project use this
 
devenv samplesolutionfile.sln /build "Debug|Win32" /project sampleSetup "Debug|Win32" in your MSBuild script.

Hari

Friday, September 5, 2014

Apart from convariance and contravariance available in assignments, parameter types and return types, it is available for genericand delegate types also from C# 4.0 onwards. Covariant types convert from a wider type to narrower type. (e.g., int  to short.).Contravariant types convert from a narrower type to a wider type(For example, from string to object.).


Example:
 Output: Contravariant
 Output: Covariant


ExpandoObject class provides us the capability to add and delete members of its instances at runtime and also to set and get values of these members. We have to use System.Dynamic namespace to use this class. We must use the dynamic keyword to enable late binding for an instance of the ExpandoObject class.


Example:
    Output :

Tuple is available from .net 4.0. It allows us to capture related values without creating a new class. It is much flexible that the KeyValuePair class, because it can hold up to 8 values of different types.


Example:

    Output:

Features of C# -Default keyword

 Default keyword
We can use default keyword to assign default value to a variable of any type. It is very useful while working in generic context.
Example:
 
new features c#

Friday, January 24, 2014

I’m working in .Net 1.1 application.

The application’s existing development environment is not stable and having same error in most of the pages in page load itself.

I’m having access to the application’s development server  shared folder only.

In my system the application is working fine. So took new build of the application, removed all the existing files in that shared folder, and copied the published files.

But still I’m getting the same error.
 

Error Message:

Server Error in the Application
Method not found: 'Void System.Web.UI.HtmlControls.HtmlForm.set_Action(System.String)'.

Kindly suggest solution.

Tuesday, August 21, 2012

Hi All,

I have a question regarding FileStream and StreamWriter. I am doing
the below IO operation in my project .But, it throws the error of "The
process cannot access the file because it is used by another process"
in below highlighted line.


string filePath = "C:/Test/Folder1"
string fileName =
DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() +
DateTime.Today.Year.ToString();
string fullFilePath = filePath + "_" +
fileName + ".txt";
FileStream fs = new
FileStream(fullFilePath, FileMode.Append, FileAccess.Write);
if (!File.Exists(fullFilePath))
{
fs = new FileStream(fullFilePath,
FileMode.CreateNew, FileAccess.Write);
}
StreamWriter sw = new StreamWriter(fs);
sw.Write("Test" );
sw.Close();
sw.Dispose();
fs.Close();
fs.Dispose();


So, If you know the solution then kindly reply me only. Thanks in advance..:)


Thanks & Regards,
Sanjiv

SOLUTION 1:

Hi Sanjiv,

You have to use using keyword to avoid such access behaviors

string filePath = "C:/Test/Folder1";
string fileName = DateTime.Today.Day.ToString() +
DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString();
string fullFilePath = filePath + "_" + fileName + ".txt";
FileMode _fm = FileMode.Append;

if (!File.Exists(fullFilePath))
_fm = FileMode.CreateNew;

using (FileStream fs = new FileStream(fullFilePath, _fm,
FileAccess.Write))
{
StreamWriter sw = new StreamWriter(fs);
sw.Write("Test");
sw.Close();
sw.Dispose();
fs.Close();
fs.Dispose();
}


More reference


http://msdn.microsoft.com/en-us/library/yh598w02.aspx

http://www.codeproject.com/Articles/17106/The-using-Keyword-in-C

-Oli.

Tuesday, August 14, 2012

Hi All,
 
I need to display the data from multiple grid view in a single PDF .I have tried to many approaches and search in Google but not getting the proper results..
Need the solution for this issue .
 
I m having 10 grid views and on button click data displayed on screen in grid view should be displayed(export) in PDF...

 

Thanks in advance for the help
 
-Khan
I am just thinking of how the voice calculator can be implement in .net. 
I have some questions. Could anyone please help me to clear my ideas on below:
1.       How the analog voice is converted into digital format(Which algorithm we use?.
2.       How then digital data is adjusted to have match with voice. I heard we use some phonemes kind of things but don’t know much.
3.       How are we storing the data in database.(Any technique or encoding scheme)
4.       How the data is going to convert into text format.(Which algo will be use?)
5.       How we going to manipulate voice. Like user say 1 plus 1 then how can we get ans as 2 in text as well as in voice form.
Please help me for above.
-Kulkarni.

Saturday, August 11, 2012

Thursday, July 5, 2012

I am inserting OLEDBObject from C# into word document. I used below code.
 
                   object classtype = Excel.XlSheetType.xlWorksheet;
                   
                   object Bookmark = (int)Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark;
                   NameBookMark = obj.DocumentName;
 
                   if(NameBookMark != missing)
                       doc.GoTo(ref Bookmark, ref missing, ref missing, ref NameBookMark).InlineShapes.AddOLEObject(ref missing, ref linktofile, false, ref AsIcon, ref missing, ref missing, ref missing);  //, ref rng);
 
 
The object gets inserted correctly. But I want the icon to appear as it’s file type. Means if the embedded object is of excel, then excel icon should be displayed. However icon without any image on it gets inserted like pasted below.
Can anyone suggest how to assign icon to this embedded object?
We have an ASP.net web forms application developed on .net 4.0 and has around 10 Pages approximately. Currently the web forms are designed only for desktop web browsers. We need to provide the business with the option of enabling it for the Mobile.
 
Options we consider:
 
o   Option 1: Create a different master and CSS3 for mobile specific devices and consider using it either on the server side or client side.
o   Option 2: Create fresh set of pages designed for Mobile and use the device finding libraries like 51degress for accuracy of prediction of device and browser.
 
Among the options, we see option 2 as suggested architectural approach because of following reasons
 
·         We have less no. of pages , so the difference in development effort between option 1 and 2 will not be significant.
·         Considering the option to enable mobile devices through CSS will be a difficult task as mobile web browsers does not support CSS3 fully.
·         Bandwidth optimization would not be taken care with Option 1.
 
Would request your inputs and views on the approaches and recommendation.
 
Thanks in Advance

Wednesday, June 27, 2012

I am developing an automated process that Add/Remove groups from particular account in LDAP based on condition.
I have used C#.Net and used Directory entry namespace for LDAP connection. I have SQL Server connection and gets all the Group distinguished names from database.
I followed below steps:
1.  Connect to LDAP
2.  Filter particular Account
3.  Get member of Property
4.  Add Group (Add Group distinguished name)
5.  Close connection.
I am able to read but not write the group.
When I try to add group, it throws below error.
Error: General –Access denied.
Note: User ID and Password has ADMIN rights for particular OU.
I have below code for LDAP connectivity.
de = New DirectoryEntry(domainADsPath + "/dc=vds,dc=enterprise", username, password, AuthenticationTypes.None)
I tried all the authentication types.
My user id and password all the ADMIN rights. Still I am not able to add group
I have below code for adding group
OpenConnection()
GroupADSPath=”CN=FS-DiabetesTest,OU=Groups,OU=Users,OU=US 55 Corporate,ou=pharma,dc=vds,dc=enterprise”
            de.Properties("memberof").Add(GroupADSPath)
            de.CommitChanges()
            de.Close()
            ‘Here Group name is FS-DiabetesTest
Any Help?

Sunday, June 17, 2012

We have requirement to read a text from scanned pdf document which has text as embedded image. We have considered using itextsharp and ghost script for this requirement. Please help us if there any other open source which would be best suitable for our requirement. Any suggestion would be really appreciated

SOLUTION 1:

You can use below Microsoft's SDK for this.

Microsoft Office Document Imaging -
http://social.technet.microsoft.com/Forums/en-US/officeappcompat/thread/93d6f285-dc98-46e2-b7e0-872bba9c4e35/[^]

I had evaluated several Third Party OCR SDK's in one of my assignment. In case if you are open for Third Party OCR SDK then search below SDK's on Google.

1) Nuance OmniPage OCR
2) Accusoft SmartZone OCR
I am facing two issues with replacing image content control by its appropriate image.
 
Issue #1: How can we replace Text Content Control in the ms Word document with the Image Content Control dynamically and replace it with Image.
 
Issue #2: Also, I have tried replacing the image content control from a ms word document with an image using open XML.  Its working when there is only one image content control.
If there are more than one content control it replaces all the images with the same image. Please suggest me how can we find out specific image content control from the document and replace it with image.
 
Below is the code I am using to replace the image content control with the image.
 
                                        ImagePart image = (ImagePart)mainPart.GetPartsOfType<ImagePart>().First();
                                        string signatureUrl = contactProfile[UserProfileProperties.SIGNATURE].Value.ToString();                                    
                                        System.IO.Stream data = Site.RootWeb.GetFile(signatureUrl).OpenBinaryStream();
                                        image.FeedData(data);
 
I already have tried with below codes, in all the cases all the image content controls in the document  are replaced by single image.
ImagePart image = (ImagePart)mainPart.GetPartsOfType<ImagePart>().Last();
ImagePart image = (ImagePart)mainPart.GetPartsOfType<ImagePart>().ElementsAt(0);