Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing multiple Projects in NotifyIcon Application
    primarykey
    data
    text
    <p>So I have the weirdest of all problems. I just wanted to write a simple c# WinForms tool for personal use when I ran into it. I`ll begin at the very start, the real question will be at the very end.</p> <p>So I made a NotifyIcon Application. This is very simple, I just did:</p> <pre><code>public class MyApp: ApplicationContext { NotifyIcon icon; public MyApp() { // ... } // ... } </code></pre> <p>And start the App just as every other WinForms App:</p> <pre><code>Application.Run(new MyApp()); </code></pre> <p>Now I have added a new MyApp.Data Class Project, which contains a Local Database, and used the edmx helper to generate my EF Models. I have added a static class called Database which should contain all my Queries.</p> <pre><code>public static class DataBase { static MyAppModel db = new MyAppModel(); public static void AddEntry(SomeThing st) { db.SomeThings.AddObject(st); db.SaveChanges(); } public static String[] GetSomeThings(int numberOfEntries) { return db.SomeThings.OrderBy(x =&gt; x.Date).Select(x =&gt; x.Title).Take(numberOfEntries).ToArray(); } } </code></pre> <p>Back in the WinForms NotifyIcon Project, I add MyApp.Data Assembly (and EF Assembly) and when I call <code>DataBase.AddEntry(x)</code> everything works perfectly fine, but when I use <code>Database.GetSomeThings(10)</code> everything breaks.</p> <pre><code>var x = Database.GetSomeThings(10); String[] y = Database.GetSomeThings(10); </code></pre> <p>just silently fails without an error. <code>x</code> and <code>y</code> both don't show up in locals and cannot be watched. Anybody got an idea?</p> <p>edit: i bound directly to comboBox and it magically worked. now i turned the autocompletemode and source on, and i get an error message:</p> <p><em>Für den aktuellen Thread muss der STA-Modus (Single Thread Apartment) festgelegt werden, bevor OLE-Aufrufe ausgeführt werden können. Stellen Sie sicher, dass die Hauptfunktion mit STAThreadAttribute gekennzeichnet ist.</em></p> <p>unfortunately german, but i think i can solve this:</p> <p><a href="http://msdn.microsoft.com/de-de/library/ms182351%28vs.80%29.aspx" rel="nofollow">http://msdn.microsoft.com/de-de/library/ms182351%28vs.80%29.aspx</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload