I'm following the following article about how to work with the OpenXML SDK:
https://msdn.microsoft.com/en-us/library/office/ff478410.aspx
I have the following code:
// Open a SpreadsheetDocument based on a stream.
SpreadsheetDocument spreadsheetDocument
= SpreadsheetDocument.Open(stream, true);
// Add a new worksheet.
WorksheetPart newWorksheetPart = spreadsheetDocument.WorkbookPart.AddNewPart<WorksheetPart>();
newWorksheetPart.Worksheet = new Worksheet(new SheetData());
newWorksheetPart.Worksheet.Save();
Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>();
string relationshipId = spreadsheetDocument.WorkbookPart.GetIdOfPart(newWorksheetPart);
// Get a unique ID for the new worksheet.
uint sheetId = 1;
if (sheets.Elements<Sheet>().Count() > 0)
{
sheetId = sheets.Elements<Sheet>().Select(s => s.SheetId.Value).Max() + 1;
}
// Give the new worksheet a name.
string sheetName = "Sheet" + sheetId;
// Append the new worksheet and associate it with the workbook.
Sheet sheet = new Sheet() { Id = relationshipId, SheetId = sheetId, Name = sheetName };
sheets.Append(sheet);
spreadsheetDocument.WorkbookPart.Workbook.Save();
// Close the document handle.
spreadsheetDocument.Close();
But I keep getting the following error:
Severity Code Description Project File Line Suppression State
Error CS1729 'Worksheet' does not contain a constructor that takes 1 arguments MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 139 Active
Error CS0246 The type or namespace name 'SheetData' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 139 Active
Error CS1061 'WorksheetPart' does not contain a definition for 'Worksheet' and no extension method 'Worksheet' accepting a first argument of type 'WorksheetPart' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 140 Active
Error CS1061 'WorkbookPart' does not contain a definition for 'Workbook' and no extension method 'Workbook' accepting a first argument of type 'WorkbookPart' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 142 Active
Error CS1061 'Sheets' does not contain a definition for 'Elements' and no extension method 'Elements' accepting a first argument of type 'Sheets' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 147 Active
Error CS0246 The type or namespace name 'Sheet' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 147 Active
Error CS1061 'Sheets' does not contain a definition for 'Elements' and no extension method 'Elements' accepting a first argument of type 'Sheets' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 149 Active
Error CS0246 The type or namespace name 'Sheet' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 149 Active
Error CS0246 The type or namespace name 'Sheet' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 156 Active
Error CS0246 The type or namespace name 'Sheet' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 156 Active
Error CS1061 'Sheets' does not contain a definition for 'Append' and no extension method 'Append' accepting a first argument of type 'Sheets' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 157 Active
Error CS1061 'WorkbookPart' does not contain a definition for 'Workbook' and no extension method 'Workbook' accepting a first argument of type 'WorkbookPart' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 158 Active
Why do I get this error messages?
Make sure you have a reference to DocumentFormat.OpenXml.dll added to your project.
Related
I try to display a chart from Microcharts, but I receive this error:
/Users/pizhev/Documents/WeatherLocationInfo 1.6.8/WeatherLocationInfo/MainPage.xaml.cs(27,27): Error CS0234: The type or namespace name 'Entry' does not exist in the namespace 'Microcharts' (are you missing an assembly reference?) (CS0234) (WeatherLocationInfo)
I fallow this link: Tutorial and before two months this method work perfectly.
So when I try to change:
using Entry = Microcharts.Entry;
to
using Entry = Microcharts.ChartEntry;
I receive a many errors like this:
/Users/pizhev/Documents/WeatherLocationInfo 1.6.8/WeatherLocationInfo/MainPage.xaml.cs(243,243): Error CS1503: Argument 2: cannot convert from 'Xamarin.Forms.Entry' to 'Microcharts.ChartEntry' (CS1503) (WeatherLocationInfo)
and this:
/Users/pizhev/Documents/WeatherLocationInfo 1.6.8/WeatherLocationInfo/MainPage.xaml.cs(44,44): Error CS1061: 'ChartEntry' does not contain a definition for 'Text' and no accessible extension method 'Text' accepting a first argument of type 'ChartEntry' could be found (are you missing a using directive or an assembly reference?) (CS1061) (WeatherLocationInfo)
So what is changed in Microcharts and how can I fix this errors ?
I am not able to build some C# code because of the following message:
Error CS1061 'IServiceProvider' does not contain a definition for 'QueryService' and no extension method 'QueryService' accepting
a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)
serviceProvider.QueryService(ref SID_STopLevelBrowser, ref guidIServiceProvider, out objIServiceProvider);
Can this be fixed by adding a reference? Which one?
Microsoft.VisualStudio.Data.dll
https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.data.serviceprovider.microsoft-visualstudio-ole-interop-iserviceprovider-queryservice?view=visualstudiosdk-2019
I'm trying to run the Code Generation for my edmx, however every time I do this, I'm being faced with lots of errors.
This is the Context.cs file is generated:
//------------------------------------------------------------------------------
/ <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace project.DAL
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class NebulabEntities : DbContext
{
public NebulabEntities()
: base("name=NebulabEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Commodity> Commodities { get; set; }
public virtual DbSet<CommoditiesPrice> CommoditiesPrices { get; set; }
}
}
The Errors I'm getting:
Severity Code Description Project File Line
Error CS0426 The type name 'Data' does not exist in the type 'System' project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 13
Error CS0426 The type name 'Data' does not exist in the type 'System' project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 14
Error CS0246 The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 16
Error CS0115 'NebulabEntities.OnModelCreating(DbModelBuilder)': no suitable method found to override project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 23
Error CS0246 The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 23
Error CS0246 The type or namespace name 'DbSet<Commodity>' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 28
Error CS0246 The type or namespace name 'DbSet<CommoditiesPrice>' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 29
I'm using Visual Studio 2015 for this, and I've added EF to my class library project.
Does anyone know why it's generating code with errors?
This is because you are referencing older entity framework dll in your project. The solution is -
1. First remove the reference of older EF dll from Reference Manager.
2. Then add the Newer EF dll by using the browser feature.
For EF 6.1.3 you will get the dll in the folder "EntityFramework.6.1.3\lib\net45"
I'm developing a classlibrary(Windows Store Apps) for XMPP in windows 8, I'm Getting these errors, I'd given all the required references like,
System.Net
System.Threading
and so on, But Still these errors arises,
Error 15 The type or namespace name 'Formatting' could not be found (are you missing a using directive or an assembly reference?)
Error 16 The type or namespace name 'Formatting' could not be found (are you missing a using directive or an assembly reference?)
Error 17 The type or namespace name 'Formatting' could not be found (are you missing a using directive or an assembly reference?)
Error 7 The type or namespace name 'ICloneable' does not exist in the namespace 'System' (are you missing an assembly reference?)
Error 9 The type or namespace name 'IPAddress' could not be found (are you missing a using directive or an assembly reference?)
Error 12 The type or namespace name 'IPAddress' could not be found (are you missing a using directive or an assembly reference?)
Error 13 The type or namespace name 'IPEndPoint' could not be found (are you missing a using directive or an assembly reference?)
Error 6 The type or namespace name 'ListDictionary' could not be found (are you missing a using directive or an assembly reference?)
Error 14 The type or namespace name 'ListDictionary' could not be found (are you missing a using directive or an assembly reference?)
Error 2 The type or namespace name 'Sockets' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
Error 3 The type or namespace name 'Sockets' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
Error 4 The type or namespace name 'Sockets' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
Error 5 The type or namespace name 'Stack' could not be found (are you missing a using directive or an assembly reference?)
Error 1 The type or namespace name 'Timer' could not be found (are you missing a using directive or an assembly reference?)
Error 8 The type or namespace name 'Timer' could not be found (are you missing a using directive or an assembly reference?)
Error 10 The type or namespace name 'Timer' could not be found (are you missing a using directive or an assembly reference?)
Error 18 The type or namespace name 'XmlTextWriter' could not be found (are you missing a using directive or an assembly reference?)
Error 11 Using the generic type 'System.Collections.Generic.Queue' requires 1 type arguments
Please anyone help me or suggest me the solution. . .
/// <summary>
/// returns the Xml, difference to the Xml property is that you can set formatting properties
/// </summary>
/// <param name="format"></param>
/// <param name="indent"></param>
/// <returns></returns>
public string ToString(Formatting format, int indent)
{
return BuildXml(this, format, indent, ' ');
}
#region << Xml Serializer Functions >>
private string BuildXml(Node e, Formatting format, int indent, char indentchar)
{
if ( e != null )
{
System.IO.StringWriter tw = new StringWriter();
XmlTextWriter w = new XmlTextWriter(tw);
w.Formatting = format;
w.Indentation = indent;
w.IndentChar = indentchar;
WriteTree(this, w, null);
return tw.ToString();
}
else
{
return "";
}
}
The 'Formatting' error is coming from this code block, Even though i've given the reference as system.xml
Theres no Option to Resolve,
Based on a quick google search for one of the comments in the code you've provided, I found that it's from here.
As this isn't your own code (I assume - perhaps incorrectly!) that you're attempting to compile for Windows Store Apps which presently targets the 3.5 framework and has references to things such as System.Windows.Forms listed in the project file, it'll likely not work until you rewrite portions of the code to target the Windows Store version of the framework. For example, XmlTextWriter is not listed under the System.Xml namespace in the [.NET For Windows Store Apps] API4.
In short - code for the "full" .net Framework cannot (other than the simplest of snippets) just be recompiled targeting the Windows Store .NET API.
I try to upload an image in my project which is in c#.and my code in the submit button is following
FileUpload1.SaveAs(
Server.MapPath("Photos\\" +
System.Core.WebSecurity.GetUserName(Request) + ".jpg"));
Response.Write(
"<html> <script> alert ( 'you have successfully uploaded' ); </script></html>");
Response.Redirect("studentcreated.aspx");
but on compiling it shows an error as
The type or namespace name 'Core' does not exist in the namespace
'System' (are you missing an assembly reference?)
.
Then i try to solve this by adding system.core to reference. But still it shows the same error. I am using vs2008 asp3.5.
Try this to get username: User.Identity.Name
EDIT:
Add this reference: using System.Web.Security;