last day (24 days later) » 

6:00 PM
0
A: Unit tests for various versions of windows

Alec RudermanWithout seeing a sample of the unit tests in question I couldn't begin to give you a more precise answer though, but here are some stabs: A unit test shouldn't fail because it's running on a different version of Windows, rather I suspect the Windows 7 machine doesn't have the same version of dot...

 
Also what exception are you seeing, or what happens when you try to run the test, some more details would greatly help.
 
No exceptions are happening on unit tests. My unit tests work within the bounds of my program but when I tried my deployed/published program on my coworkers environment the program would load do a few things and then silently crash out. I just wanted to set up my unit tests so an exception would be thrown on methods that would fail on my coworkers environment. So I should check my coworkers dotnet installed version?
 
That is possible, but I would have expected a warning when you installed it on your co-workers machine. What did you build the installer with? It never hurts to make sure he has all of the latest versions of the dotnet framework installed. Do you have any logging in your application? Consider outputting some simple logging to see what exactly is going on in your application. Failing that use a try/catch block around your primary entry point and pop up a modal with any errors it catches as a down and dirty way of seeing what's going on.
 
One click deployment. Note: No one has admin access so I can't install something that requires admin credentials to install.
 
I added this to the edit, so not sure if you saw it, "Do you have any logging in your application? Consider outputting some simple logging to see what exactly is going on in your application. Failing that use a try/catch block around your primary entry point and pop up a modal with any errors it catches as a down and dirty way of seeing what's going on."
 
6:00 PM
Since my coworker isn't a programmer and they need their computer to do their work I don't have access to it all the time. (Like today where they are working from home on an important "Do not disturb me" task.) The logging I had told me that the program hung up on a lock variable that I use to get my threads to wait to access the MS Access DB. I assume the previous thread crashed and never released the lock. That's as far as I got before my coworker left on Friday. Now its Monday and I'm trying to find out how to debug it without having to have their actual computer in front of me.
Hi there.
First time I use chat
 
So the thing about this issue that's a red flag for me, is that dotnet by design is intended to run the same everywhere the framework can run.
 
Since this is my first WPF program. Could I have badly set up my project at the beginning?
 
So I doubt it's a Window's 7 specific issue, but possibly a result of as you said lock not being released. Do you have your threads wrapped in try/catch/finally blocks so that they will exit gracefully and clean up after themselves?
Most definitely, and we all have to start somewhere, welcome to the craft.
I'm not a WPF expert, but I have been in dotnet since version 1, mostly back-end server side
 
I do have some directly when trying to access the DB but I've had trouble before to release all the interop.
Thank you
Any easy way to copy and paste code in the chat?
 
not that I'm aware of
you can just try
I can clean it up if it gets formatted goofily
 
6:04 PM
public partial class MainWindow : Window
{

public MainWindow()
{

AddREsources();
InitializeComponent();

}

private void AddREsources()
{
System.Windows.Application.Current.Resources.Add("ConnectionManager", new ConnectionManager());

}
looks not to bad. This is where I add my connection manager to resources to make sure I only use one instance of the open applicaton
 
Are you familiar with Inversion of Control?
 
No I am not.
 
ok, the best way to accomplish what you're trying do is to have a class that wraps the connection manager class. It should create a single instance when it is initialized and be available through an accessor
 
Ah thats what my connection_manager was suppose to do with my connection.
so it would replace my connection manager.
 
Can I see the code for your ConnectionManager?
 
6:11 PM
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Analytics_Module.Utillity
{
public class ConnectionManager
{
[DllImport("user32.dll")]
static extern int GetWindowThreadProcessId(int hWnd, out int lpdwProcessId);

//Old Code for tying to resolve flashing access window.
//[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
//public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy,
 
woah ok so key point here, you're exiting out of dotnets managed code here and this is likely the cause of all the funkiness you're experiencing on your co-workers machine
check this link out for a client way to pull in the resources you need
 
K will do give me a second
Just for added info here is the static class that uses the above.
using Microsoft.Office.Interop.Access;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.OleDb;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Xml.Linq;
using Analytics_Module.Models;

namespace Analytics_Module.Utillity
{

static class ConnectionDatabase
{
[DllImport("user32.dll")]
 
but since you're accessing Excel an Access there could be some difference between the Windows 7 and Windows 10 versions of the applications. Can you confirm if you're 64-bit OS or 32-bit, same with your co-worker, because that will also cause issues with DLLImport
 
I've confirmed that we both have 64-bit.
At least that is what the IT person told me early on in this.
 
are you new to programming BTW, because this is some heavy lifting work with interop and COM
good that simplifies things by a huge degree
 
6:21 PM
New to C# but I have a very good base in other languages (VBA, JS, PHP, ...) first real multi threaded program and first time I need it to run on environments other than my own.
ignoring browser compatibility issues I've had before with js.
 
cool, dotnet is really powerful, you've just been tasked with a pretty complex solution working with excel and access; it's always been awkward interfacing with MS Office and surprisingly hasn't gotten any easier. What is the general purpose of this app?
 
Report generation. I creates a visible report in a window view and if the user wants generates excel files with the reports. This is a middle step. The data for the reports is stored in an Access file (note it seems we don't have ado installed that why DAO is used) but as soon as this report program is done. My next task will be to migrate the access db to an ms sql server.
I create* not "I creates"
 
Ok, here's my thoughts, you shouldn't need to use automation for getting data out of Access, even DAO should be able to work over ODBC
 
So you think connecting to the DB isn't what is causing my coworkers application to silently fail.
 
No not saying that, was trying to reduce cyclomatic complexity to simplify debugging
one less interop to pull in
 
6:29 PM
ah ok.
 
use standard sql to access the data
 
Nothing out of the norm. Normal SQL that I've tested directly in the Access DB. Output Apps desired query. Copy paste query in new query in Access. Run query and it works.
The data in the DB is a little polluted if that could be it. ie: hidden <tab> characters in strings.
string filterTable = $@"
SELECT
*,
SWITCH(
[% of Floor] = -1, 0,
[Size] > 0, [Size],
[% of Floor] > 0,
[% of Floor] * [Floorplate]
) AS [Suite Size]
FROM (
Tenants_Master
INNER JOIN Properties
ON Tenants_Master.[Property ID] = Properties.[Property ID]
)
LEFT JOIN Properties_FloorTraits AS pft
ON pft.[Property ID] = [Tenants_Master].[Property ID]
AND pft.[Floor] = [Tenants_Master].[Floor]
WHERE Current = true {sqlWhere}
";
 
it all depends on the full error stack and where precisely things are going off of the rails
is this an internal only app? That {sqlWhere} block could be taken advantage of
 
Yes this is internal only. I have plans to prevent SQL injection on user input validation.
using user input validation.
and once I'm using the MS SQL server I'll hopefully find a way to bind variable to query parameters
 
Also consider looking into OpenXML, it is Microsoft's library for writing directly to files to generate excel documents. I used it in 2006-2008 and I've heard it's only gotten better
"and once I'm using the MS SQL server I'll hopefully find a way to bind variable to query parameters" this is super simple I have no doubt you'll pick up on it quickly
 
6:37 PM
Noted. I'll do some reading into OpenXML.
 
Good luck, I've got to run to a meeting.
 
k thank you
 
Sorry I couldn't help more
 
no worries you still helped.
thank
thank you
 

last day (24 days later) »