UWP PdfDocument does not contain a constructor that takes 0 arguments - c#

I get an error 'CS1729 'PdfDocument' does not contain a constructor that takes 0 arguments'
This is the simplest code and it doesn't compile.
`using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.Data.Pdf;
namespace IB
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
}
}
}`
I have tried putting a write stream as an agreement but it still doesn't work.

Related

windows phone "Error 24 Type X' already defines a member called 'X' with the same parameter type"

I have got the error :
Error 24 Type 'X.volSays' already defines a member called 'volSays' with the same parameter types
The code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
namespace X
{
public partial class volSays : PhoneApplicationPage
{
public volSays()
{
InitializeComponent();
}
}
}
How do I fix this error ?

Unable to load dll when inheriting from a form

I'm trying to create a new form (child form) that inherits from another form (parent form), and the problem is that, when I try to view the child form design view (in order to modify some controls), Visual Studio throws the following error: "Unable to load DLL 'fmodex': the specified module could not be found inherited form. (Exception from HRESULT: 0x8007007E)". The strange thing is that it actually works fine when I run the program, the error is only shown when I try to enter to the design view of the child form. I've checked the dll path and it's correct. Here's part of the the parent's code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
protected EventList eventList;
protected FMOD.System system;
protected int count;
public Form1()
{
InitializeComponent();
//Create a FMOD System object and initialize.
FMOD.RESULT result;
result = FMOD.Factory.System_Create(ref system);
result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
//Event list
eventList = new EventList(0,system);
count = 0;
}
}
}
And the child's code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : WindowsFormsApplication1.Form1
{
public Form2()
{
InitializeComponent();
}
}
}
Does anybody knows what could be happening? I can't understand why I can see the design view of the parent form and not the child form one.
Thanks in advance.

Unable to programmatically set form background image from picture resource

I just want to set the background image of another form to a png file picture resource I added
I have the following in my MAstrategyBldrForm.cs file:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MAStrategyBuilder
{
public partial class MAstrategyBldrForm : Form
{
private CrossPicsForm crossPic;
public MAstrategyBldrForm()
{
InitializeComponent();
crossPic = new CrossPicsForm();
}
....
....
.... later in same file:
private void MAcrossPicButton_Click(object sender, EventArgs e)
{
crossPic.BackgroundImage = (Bitmap) (Properties.Resources.ResourceManager.GetObject("Moving Avgs Cross.png"));
crossPic.Show();
}
....
....
In my CrossPicsForm.cs file I have:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MAStrategyBuilder
{
public partial class CrossPicsForm : Form
{
public CrossPicsForm()
{
InitializeComponent();
}
}
}
Everything compiles but when I click my button control in the mastrategy... form, a CrossPicsForm window is displayed that is blank. Darn!
You won't get an exception when you mis-spell the resource name, ResourceManager simply returns null and that leaves the BackgroundImage property unchanged. You did, it would normally be named "Moving_Avgs_Cross" without the .png extension.
Do favor using the property that was added by the resource designer instead. That ought to resemble:
crossPic.BackgroundImage = Properties.Resources.Moving_Avgs_Cross;
Use IntelliSense to help you fall in the pit of success here.

bringing two projects together

I have a simple window application I am starting and I was given another file I would like to bring into the new project. How do I bring them both together to work as one file?
New Project
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Other
using System;
using System.Text;
using System.IO;
using System.Net;
namespace CaptchaClient
{
public static class SampleUse
{
public static void SampleSolve()
{
}
}
public class CaptchaSolver
{
}
public enum ResponseState
{
}
}
This screenshots shows the how yo do he procedure
Right click on your project in the Solution Explorer and click Add Existing Item. Then browse to the other class file. Once imported, you might want to change its namespace to the one you are using in your project.

ASP.NET Syntax and conventions

I am reading Designing Evolvable Web APIs with ASP.NET. In one of the exercises, the book has me edit a Controller using Visual Studio. This is being done in ASP.NET using C#. The template I used was the standard ASP.NET web application API.
I have edited the controller to the way the book shows (although it does not seem to give very specific directions). Here is what my controller looks like.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Http.ModelBinding;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OAuth;
using WebApplication4.Models;
using WebApplication4.Providers;
using WebApplication4.Results;
namespace WebApplication4.Controllers
{
public class GreetingController : ApiController
{
public string GetGreeting() {
return "Hello World!";
}
}
public static List<Greeting> _greetings = new List<Greeting>();
public HttpResponseMessage PostGreeting(Greeting greeting)
{
_greetings.Add(greeting);
var greetingLocation = new Uri(this.Request.RequestUri, "greeting/" + greeting.Name);
var response = this.Request.CreateResponse(HttpStatusCodeResult.Created);
response.Headers.Location = greetingLocation;
return response;
}
}
I get errors on:
_greetings: A namespace cannot directly contain members such as fields or methods
PostGreeting: A namespace cannot directly contain members such as fields or methods,
_greetings : does not exist in the current context
Request : <invalid-global-code> does not contain a definition for 'request',
Created: HttpStatusCodeREsult does not contain a definition for 'Created'
As the error is trying to tell you, your fields and methods must be inside the class.
Check your braces.
Your _greetings field needs to be part of the class, as well as the PostGreeting method, it seems you just closed "}" of the class a bit early.
MOve the "}" before the _greetings field to the end of the file, like:
namespace WebApplication4.Controllers
{
public class GreetingController : ApiController
{
public string GetGreeting() {
return "Hello World!";
}
public static List<Greeting> _greetings = new List<Greeting>();
public HttpResponseMessage PostGreeting(Greeting greeting)
{
_greetings.Add(greeting);
var greetingLocation = new Uri(this.Request.RequestUri, "greeting/" + greeting.Name);
var response = this.Request.CreateResponse(HttpStatusCodeResult.Created);
response.Headers.Location = greetingLocation;
return response;
}
}
}

Categories

Resources